08-09-2017 10:00 AM
I am new to APIs and trying to develop a simple pipeline.
I am authenticating and then searching by first name and last name and expecting the call to return the IDs associated with the person (in this case Roy Graham).
In the pipeline I am first using a Rest Post to Authenticate and then using a mapper to parse out the authentication parameters from the response header that are needed for the subsequent post/get calls. I am then using a copy / join those headers with a JSON generator. In the JSON generator I am inputting request body that I need in order to make the Rest Post Search call.
{
“FirstName”: “Roy”,
“LastName”: “Graham”
}
However I am getting a user not authorized error in the Rest POST call. I do not receive the same error when using a REST get call which leads me to believe its how I am handling/inputting the request body? What is the best way in Snaplogic to input the request body into a Rest Post call?
“error_entity”: “{“message”:“User not authorized”}”
Any assistance is greatly appreciated (11.7 KB)
08-09-2017 01:18 PM
Not sure why you are copying and joining back?
If it is just to add the firstname and lastname to the document, then you can do all of them in one single mapper. You could be done in just 3 snaps. Here I do in 4 snaps.
$ or whatever variable you want to pass can be put in HTTP entity of the Rest POST
First thing is to make sure this works from your PostMan before making this work on this platform.
This will give you a validation on what to pass and what not to pass.
Hope that makes sense.
08-09-2017 01:26 PM
Are you sure you are constructing the correct Cookie value? What API is this?
08-09-2017 03:29 PM
Hi there,
To answer your questions.
Not sure why you are copying and joining back?
I used the copy and join because I thought I needed the json formatter for the request body. Should I be able to include the request body in a mapper and not need to include a json formatter?
I removed the json generator and inputed the firstname and lastanme into the mapper and get the same error
Are you sure you are constructing the correct Cookie value? What API is this?
Yes I am constructing it based off how it is successful in SOAP UI and it is a POST call. There are two header values i am parsing out that are sucessful in the GET call. However using the same logic they are unsuccessful in the POST call.
"headers": {transfer-encoding:chunked, content-type:application/json, server:Jetty(8.1.19.v20160209), date:Wed, 09 Aug 2017 22:19:26 GMT, cache-control:no-cache}
“transfer-encoding”: “chunked”
“content-type”: “application/json”
“server”: “Jetty(8.1.19.v20160209)”
“date”: “Wed, 09 Aug 2017 22:19:26 GMT”
“cache-control”: “no-cache”
"statusLine": {protoVersion:HTTP/1.1, statusCode:200, reasonPhrase:OK}
“protoVersion”: “HTTP/1.1”
“statusCode”: 200
“reasonPhrase”: “OK”
"original": {Token:XSRF-TOKEN="89d9SyfstQrAUVP5YpCT2DXM67vuP/5SdhYXFsPsU7s=", SessionID:mv77df1cijnssyyzqn1f1wip, JSESSIONID:null}
“Token”: “XSRF-TOKEN=“89d9SyfstQrAUVP5YpCT2DXM67vuP/5SdhYXFsPsU7s=””
“SessionID”: “mv77df1cijnssyyzqn1f1wip”
“JSESSIONID”: null,
"entity": {euid:1000501093}
“euid”: “1000501093”
08-10-2017 07:15 AM
Yes I have repeated in SOAPUI and it is successful.
I have raised an internal thread and waiting for feedback.