I have been trying to create a very simple Logic App in Azure but I keep failing because it does not seem to be accepting my JSON.
Using my payload
{
"userPrincipalName": "notmy#ddress.com",
"computerName": "MyComputername"
}
I created the trigger
I then use the values of my payload in my response:
Save it and then I POST using Hurl.it to the HTTP POST URL in the request.
So why the heck is the value not used? I'm not able to use any of the values I'm sending.
Okay.. that was dumb..
I had to add the Content-Type header to the POST:
Related
I have to use raw json in my post query to Azure Key Vault. Which I've done like so:
{ "grant_type":"client_credentials" }
I get a 400 error complaining that the body does not have 'grant_type'
How can I get Azure Key Vault API to accept the raw json body?
The headers are in the attached image
headers
body in Postman:
body
using urlencoded in raw-JSON body
The endpoint is: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token which returns a temporary access token.
Microsoft has confirmed with me that this endpoint cannot accept raw-JSON so I'll have to find some other way for my implementation.
Your post data needs to be URLEncoded. This can be done in Postman using a pre-request script. You can read the full walk-through on Jon Gallant's blog here: Azure REST APIs with Postman or watch the video here: https://learn.microsoft.com/en-us/rest/api/azure/
This endpoint cannot read raw JSON.
The only solution is to modify the request body to use urlencoded format.
In Postman this can be done by changing the content type to: application/x-www-form-urlencoded
and the body to Raw with the content inside the body as &{key}={value} for every key, value that the endpoint requires.
Without access to the API sending the request I'm unfortunately unable to solve this issue since I'm forced to use JSON objects as the request body.
I am trying to create a PUT request where admin will be making decision based on some criteria and Verifying or Rejecting a user. I expect this decision in JSON body(Refer to Verification method in below image). But I am confused what json body should I send. I have sent the following JSON body { "REJECTED" }
{ REJECTED }
REJECTED
But everytime, it is returning false in the above method. Please help!!
You are not returning any JSON here - your method type is void.
You need to return something maybe string or response itself.
Using System.out.println(), you are displaying the message on your console only but not sending a response to the server.
I want to use data i have parsed form precious service and make post request for writing this data in another databasei in postman my post request looks like this :
and here is my http connector post request exmple:
The parameter is called payload and not body.
See camunda documentation about connector.
For our application, we are supposed to write the test scripts which test our REST API.
So I have written individual tests in postman in a collection. When ran individually, all tests pass.
Now to run all tests sequentially in a collection, I want the output of the first GET request (the response is an array of JSON objects), to pass as input body to next POST request.
The following code is written as a test in Tests of GET request.
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("data", jsonData);
postman.setNextRequest("POST request");
I have named my post request as "POST request". But this test is failing.
Please let me know if I have done any mistakes.
You're trying to set the entire JSON as an environment variable instead of property value. Try to change your line like this.
const jsonData = pm.response.json();
pm.environment.set('data', jsonData);
Later, use that environment variable as input to your POST request as {{data}}
Considering your JSON response is something like this.
{
"status": "SUCCESS",
"message": null,
"error": null,
"id": 1234
}
Hope I answered your question. I have recently written a blog on automating API's using postman you can refer here API Automation using postman
Let us know if it solves your problem.
Ah!! Missed this point.
If you want to send the entire JSON as input then use JSON.stringify()
Similar question asked
The data should be set as part of the request for the POST operation.
Within Postman, in the body section for the POST request, you can set the data onto the request, either as a form field value or as the entire request body i.e. raw e.g.
{{data}}
Some additional information and examples are here: https://www.getpostman.com/docs/postman/environments_and_globals/variables
I created a sample AWS lambda function and integrated this function with AWS API.
I have written a post method in API and selected application/JSON whose request integration mapping is as below.
{
'songTitle':"$input.params('songTitle')"
}
songTitle is being sent as parameter (application/JSON) with request to API.
However I am receiving $input.params() as empty.
As I am new to this I have no idea what is the correct way.
Please guide to access these params
I'm not sure if this is your issue, but single quotes are not the same as double quotes in JSON. Anything in the mapping template that isn't escaped with the $ character is written as-is in the actual payload.
Should be:
{
"songTitle":"$input.params('songTitle')"
}
Edit: If that doesn't work, please also test by sending the Content-Type header in the request as application/json. If you don't send Content-Type at all, it should default to application/json mapping template.
In case of reading input parameters from request header part (for request integration mapping)
syntax:
{
'songTitle':"$input.params('songTitle')"
}
If we want to read parameters from request body part we should write as
{
'songTitle':"$input.path('$.songTitle')"`enter code here`
}