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!