Update a Google Sheet Using HTTP Request in Postman - google-api

I have a server needing to update a shared Google Sheet. It generates special tokens for offline use so doesn't work with PHP quickstart module.
I am trying to setup request in Postman for this action:
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update
But get the following result:
Is it possible to use HTTP for this API?

Turns out I had to add ?valueInputOption=RAW on the end of my URL request and removed valueInputOption from the request body JSON.

The valueInputOption should be passed as params to the POST URL, it should not be in the request body.
Also the sheetID and the range should be sent in the URL.
I suppose it should be a POST call not PUT.

Related

How to remove request body from subsequent requests in JMeter

I tried to create a test script in JMeter where I log in by using API. I created a test script by BlazeMeter chrome extension.
Some of my API calls fail because I am getting CloudFront error. I found out the issue is that GET requests contain a request body. GET requests cannot contain a request body on CloudFront. When I tried the same get requests in postman without request body, I didn't get any errors. I got the same error in postman if I added a body request. This way I can confirm this is the issue.
I am looking for a way how to remove body request from subsequent GET requests in JMeter to get rid of this error.
This is the original API call (sampler) with POST login api request:
After the POST request there is a redirection to a page that makes other GET api calls to fetch static files such js files, etc. The problem is that these GET requests also contain the same request body as the original POST call.
As you can see I can fetch statis files if I remove body request:
I tried to add preprocessor and postprocessor for original POST request, but I don't know how to access subsequent GET requests. I can access only original POST request:
Is there a filter or a way how to remove body request from GET requests?
I don't think it's possible, at least not with JMeter 5.5
If you take a look at HTTPSamplerBase source code you will see that the request body is being copied fully from the original HTTP Request sampler:
this.sampler = (HTTPSamplerBase) base.clone();
So the options are in:
Raise an enhancement requests via JMeter Github Issues
Amend HTTPSamplerBase code to remove the request data from generated AsyncSamples
Handle embedded resources download manually using Parallel Controller

ServiceNow Scripted REST API GET with Body

I setup a GET scripted rest API. However, when I try to send a GET request with a body, ServiceNow (before it hits my code) complains that GET is not allowed to have a body.
Is there a way to disable this restriction? For now as a temporary workaround, I converted the request into a POST. However, this request does not change any state, so I believe it should be a GET. The request only searches for existing items.
GET is used without body, any configuration of a GET is in the URL and header. A query URL looks like this:
https://instance.service-now.com/api/now/table/problem?sysparm_query=active=true^ORDERBYnumber^ORDERBYDESCcategory&sysparm_limit=1
See the documentation here:
https://developer.servicenow.com/app.do#!/rest_api_doc?v=madrid&id=r_TableAPI-GET
Generally it's OK to use a POST to get data, graphQL does this for example, but i think SNOW is configured for GETs only.

how to attach the token in the header by automation script in postman

I am trying to automate API testing using Postman. Apart from AuthAPI every other API is decorated with [Authorize] so I need to pass token.
In my collection, the first API is AuthAPI, This API returns the JWT token.
if I run the API in collection runner, I am getting 403 error for all the APIs in the collection.
However, If I do manually copy the token recieved in the AuthAPI resonse & paste in the Authorization header, it returns the desired response.
How do I attach the token received in the response of the AuthAPI in the header of the subsequent request (Postman) when running the API in the Automated way.(via Collection Runner)
Thanks
You can use the environment variable to store the token an use them in the subsequent request. Also, the first request should be Auth API.
Check the postman console for the request details, You might have encountered the issue similar to this thread. Check whether the header has bearer or Authorization in the request details.
use variables inside Postman and Collection Runner
http://blog.getpostman.com/2014/02/20/using-variables-inside-postman-and-collection-runner/

Apiary: Full URL on responses

My API return the full host URL, and in Apiary every user has it's own private URL for the mock server.
There's a way to use this URL in the response body?
For now I'm using my own URL in the response body.
Currently, there is now way to do that as responses are statically mocked up. It is planned as the response templating, but there is no ETA yet.

IIS URL Rewrite - Convert POST to GET

In my application there is a client and a WCf REST service. For invoking some wcf service the client is doing an http POST even though the service is a GET.
i do not want to do any changes in the client or the service.
So is there a way where i can convert this POST request to GET and add the data coming in as the POST to the URL and invoke the REST service.
Thanks in advance.
You can use URL Rewrite to issue 3xx Redirect which will use GET method, but you will loose all POST data.
The only safe way known to me is to rewrite POST request to some another custom page, where you:
collect all POST data/variables;
convert them into GET variables (assemble proper GET request);
issue 301 (or 302) Redirect to the proper URL (it will have all POST data sent as GET variables).
Such rewrite to custom page should be easy -- you need to check what method is used (POST or GET) and only invoke it on POST. The rest will be handled in that post-to-get script.
The reason for all of this complexity is the difference in how POST and GET requests work: with GET all data is sent as part of URL while POST uses request body to transfer variable's data.

Resources