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

Obtaining response from JSON Post command

peter
New Contributor III

Hi

I have a pipeline which takes data from a SQL select command and posts to a Service Now API to create a task. Service Now responds with the IDโ€™s of the tasks which I want to post back to the SQL.

However when I run the POST command in Snaplogic, I seem to get no response back, the circle is blank. I know the API has worked as I can see the tasks in Service Now and If I run the API command in Postman, I get the IDโ€™s returned.

How do I see the JSON response from the REST POST Snap?

22 REPLIES 22

RavNeu
New Contributor II

I am trying to achieve similar goal. I put the file writer after JSON Formator snap to see the output format.
below is the output I am getting:

{
โ€œresponseโ€: {
โ€œstatusLineโ€: {
โ€œprotoVersionโ€: โ€œHTTP/1.1โ€,
โ€œstatusCodeโ€: 200,
โ€œreasonPhraseโ€: โ€œOKโ€
},
โ€œentityโ€: {
โ€œdocumentโ€: {
โ€œidโ€: โ€œtime_to_salesforceโ€,
โ€œrowsโ€: [{
โ€œrowโ€: {
โ€œrsIdโ€: โ€œXT_MF_TM_SF_1โ€,
โ€œdataโ€: {
โ€œXT_EMPLOYEE_IDโ€: โ€œA00000โ€,
โ€œXT_ENTERED_HOURSโ€: 8,
โ€œXT_FIRST_NAMEโ€: โ€œXXXXXโ€,
โ€œXT_GLC_IDโ€: โ€œXXXโ€,
โ€œXT_HOURS_DATEโ€: โ€œ2022-09-30T00:00:00โ€,
โ€œXT_LAST_NAMEโ€: โ€œXXXโ€,
โ€œXT_MODIFIED_BYโ€: โ€œ100000000โ€,
โ€œXT_PAYROLL_EMPLOYEE_IDโ€: โ€œX000000โ€,
โ€œXT_PAY_TYPEโ€: โ€œRโ€,

I want to load this into sql server table, so I used mapper after JSON Parser. Below is the expression I used in mapping source side:
JSON.parse($response.entity.document.rows[0].row.data.XT_EMPLOYEE_ID)
But it says unable to parse JSON value.

what expression should i use to pick this field and load into sql table?

Also, I got my response as an array rows. So, how will i be able to pick all the rows within the array?

thank you for your response in advance!!

Hi @RavNeu, are you able to provide a screenshot of your pipeline? Just from the description alone it sounds like you want a JSON Formatter Snap before the Mapper to split on the rows array so each row becomes itโ€™s own document. For example, if you have some data like this:
image

You could use a JSON Splitter to split on โ€˜jsonPath($, โ€œresponse.entity.document.rows[*]โ€)โ€™:
image

Then your Mapper could be configured like this:
image

Here is the short pipeline I built to demonstrate this in case it helps you to import it and visualize it:
QuickJSONArraySplitExample_2023_05_16.slp (5.5 KB)

RavNeu
New Contributor II

@rsramkoski thank you! it worked!