cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Request Body in Rest API Pipeline

giselle_rayner
New Contributor

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 appreciatedImage (11.7 KB)

search_join

8 REPLIES 8

nganapathiraju
Former Employee

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.

image

$ or whatever variable you want to pass can be put in HTTP entity of the Rest POST

image

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?

giselle_rayner
New Contributor

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?
image

I removed the json generator and inputed the firstname and lastanme into the mapper and get the same error
image

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โ€

image

image
image

Yes I have repeated in SOAPUI and it is successful.

I have raised an internal thread and waiting for feedback.