Request Body in Rest API Pipeline

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!NG_Join_Search_2017_08_09.slp (11.7 KB)

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.

Are you sure you are constructing the correct Cookie value? What API is this?

Hi there,
To answer your questions.

  1. The API calls work in SOAP UI (application suggested to use by the vendor instead of postman because of issues with how the cookies do not authenticate correctly in Postman). The call works without issue in SOAP UI. I have attached a screen shot. In addition the GET call is successful in SL but I’m only having issue with the POST call.

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”

            "entity":  {euid:1000501093} 

“euid”: “1000501093”


Yes I have repeated in SOAPUI and it is successful.

I have raised an internal thread and waiting for feedback.

Thanks @tstack

It is now successful.

Few things to note:

HTTP calls are very finicky about syntax and well formation of the attributes.

There needs to be a space after the semi-colon in the cookie header:

‘JSESSIONID=’ + $SessionID + '; ’ + $Token

Also, the X-XSRF-TOKEN header should have just the token value and not ‘XSRF-TOKEN="…"’. I extracted the token like so:


see the query variable how it is formed.

query: ‘{“FirstName”:"’+$FirstName+’", “LastName”: “’+$LastName+’”}’

Attached is my pipeline.

NG_Join_Search1_2017_08_10.slp (8.5 KB)

1 Like

This is great! Thank you so so much. I have been banging my head over here.

2 Questions.

  1. What is the significance of Accept-Encoding? Do I need this in all subsequent calls?
  2. If I wanted to send multiple patients (Liz Smith, John Snow, Barry White, etc) in the call how could I do this? Would you suggest creating a data file and then read from that in the post call?

Please refer to Accept-Encoding details here

If you want multiple patients sent - I am assuming in one single call, you just have to make an array. Hoping that the REST POST will accept the format.

    "FirstName": "Liz",
    "LastName": "Smith"
    "FirstName": "John",
    "LastName": "Snow"
    "FirstName": "Barry",
    "LastName": "White"

You can read from a data source such as a table and use the Group By N to collect them into an array like the above. There are other ways of doing this as well but you can try the above method first.

If this is not what you want, let me know.

Hello again,
I was able to successfully multple search. However I am now running into the same issue with the PUT call that I was running into with the Post call (user unauthorized). I have formatted (or at least I think I have) the headers vars exactly the same. Any thoughts as to why the something needs to be different in the PUT call then the POST call.

In the pipeline I have the post callNG_UpdSysRec_2017_08_21.slp (12.8 KB)
that is successful as well as the PUT call that is unsuccessful.

Any help is great appreciated!