Unable to update a specific spreadsheet row using API - google-sheets-api

I tried to update a spreadsheet row as given here Protocol tab.
Few Questions:
How do I get gd:etag? None of my workbook requests or /full requests contains info about eTag.
So I tried to send a PUT request without etag and getting an error message "Unexpected resource version ID".
Can some one point me where am doing wrong?

Related

Using Microsoft Access VBA to Update Teamup Calendar via API

I'm an experienced VBA programmer but have little experience with API's.
My goal is to use VBA to add an event to a Teamup calendar with the click of a button. The required data is present in the database, I have a Teamup API key and Teamup has provided the following rules:
API access MUST be done over TLS/SSL via https://api.teamup.com/
All API requests must include an API key in a request header
Strings in requests and responses MUST be using the UTF-8 character set
Successful responses will have status codes in the 200-299 range
Client errors will have status codes in the 400-499 range
Server errors will have status codes in the 500-599 range
Placeholders in URL examples are indicated by curly braces, e.g. {eventId}
API responses are in JSON using the application/json content type
Any help figuring this out, or in pointing me to the right resources would be appreciated.
I've played around with CreateObject("MSXML2.XMLHTTP"), but not sure if I'm on the right track.
In advance, thank you!

REST API: What HTTP return code for no data found? [duplicate]

This question already has answers here:
What is the proper REST response code for a valid request but an empty data?
(28 answers)
Closed 1 year ago.
If someone could please help settle this argument we might actually get this system finished LOL :^)
So, if you have a REST API.. for.. say.. returning patient details...
And you send in a request with a patient id...
But no patient with that patient id actually exists in the database..
What response should your API return?
1. a 404 ?
2. a 204 ?
3. a 200 with something in the body to indicate no patient found..
Thanks
Use a 404:
404 Not Found
The server can not find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean
that the endpoint is valid but the resource itself does not exist.
Servers may also send this response instead of 403 to hide the
existence of a resource from an unauthorized client. This response
code is probably the most famous one due to its frequent occurrence on
the web.
From MDN Web docs https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
What response should your API return?
It Depends.
Status codes are metadata in the transfer of documents over a network domain. The status code communicates the semantics of the HTTP response to general purpose components. For instance, it's the status code that announces to a cache whether the message body of the response is a "representation of the resource" or instead a representation of an error situation.
Rows in your database are an implementation detail; as far as REST is concerned, there doesn't have to be a database.
What REST cares about is resources, and in this case whether or not the resource has a current representation. REST doesn't tell you what the resource model should be, or how it is implemented. What REST does tell you (via it's standardized messages constraint, which in this case means the HTTP standard) is how to describe what's happening in the resource model.
For example, if my resource is "things to do", and everything is done, then I would normally expect a GET request for "things to do" to return a 2xx status code with a representation announcing there is nothing to do (which could be a completely empty document, or it could be a web page with an empty list of items, or a JSON document.... you get the idea).
If instead the empty result set from the database indicates that there was a spelling error in the URI, then a 404 is appropriate.
It might help to consider a boring web server, and how retrieving an empty file differs from retrieving a file that doesn't exist.
But, as before, in some resource models it might make sense to return a "default" representation in the case where there is no file.
if you have a REST API.. for.. say.. returning patient details...
Is it reasonable in the resource model to have a document that says "we have no records for this patient"?
I'm not a specialist in the domain of medical documents, but it sounds pretty reasonable to me that we might get back a document with no information. "Here's a list of everything we've been told about this patient" and a blank list.
What response should your API return?
If you are returning a representation of an error - ie, a document that explains that the document someone asked for is missing, then you should use a 404 Not Found status code (along with other metadata indicating how long that response can be cached, etc).
If you are returning a document, you should use a 200 OK with a Content-Length header.
204 is specialized, and should not be used here. The key distinction between 204 and 200 with Content-Length 0 is the implications for navigation.

I 'm not connect my backend api with react-admin. Ocurred error:

Warning: Missing translation for key: "The X-Total-Count header is missing in the HTTP Response. The jsonServer Data Provider expects responses for lists of resources to contain this header with the total number of results to build the pagination. If you are using CORS, did you declare X-Total-Count in the Access-Control-Expose-Headers header?"
From the error it seems your API is not returning the X-Total-Count header. react-admin uses this header to create the pagination information (by default react-admin only requests and displays 10 records max per page, but it needs to know how many total records would have been returned had it not requested a maximum of 10, so that it can show you how many pages you can click through).
See the section "JSON Server REST" in the react-admin RestClients documentation page:
JSON Server REST - X-Total-Count
Also, for an example implementation of the X-Total-Count header for an existing REST API, see the package loopback3-xTotalCount, which can be used to add the X-Total-Count header to a loopback3 REST API:
loopback3-xTotalCount

Trying to create a GET request to pubgtracker

I am trying to practice my developing and wanna build my own desktop application using: https://pubgtracker.com/site-api
Before I even start the project I want to make sure that I manage to receive information from the PUBG api. Therefore I opened https://www.hurl.it/
and I try to enter the following:
GET request, and in the destination https://api.pubgtracker.com/v2/profile/pc/{pubg-nickname} (for example lucifini1 currently ranked #1)
In addition they request the API key as a header so I did the following:
+ ADD HEADER,
In the name field added TRN-Api-Key
and in the value I added my key.
When I launch request i get an: internal server error.
How can I debug it and know what I am missing?
Am I doing it correctly?
Thanks

Rest API Returning HTTP Status Code

I have a scenario where my API application contacts external datasources and for this particular example, my API requests a list of colours from the external datasource. Sometimes the datasource doesnt have these colours and returns a plain text response of "There are no options to display" with a HTTP status code of 200 OK.
What i am wondering is what status code i should return to the client which is consuming my API in this scenario? A 404 not found or 204 no content...? Im not sure what would fit best.
Thanks
Is it valid not to return any colours? In which case your original 200 may be the right status code to use.
204 is normally used to indicate success, but the client need not update any information it holds; deleting or updating a resource for example are valid times to use 204.
404 seems wrong if the same URL is being accessed, in your scenario it sounds like the state of resource may change overtime (and it may be empty), but it always exists.