โ03-13-2020 03:20 AM
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?
โ05-16-2023 11:52 AM
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!!
โ05-16-2023 12:48 PM
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:
You could use a JSON Splitter to split on โjsonPath($, โresponse.entity.document.rows[*]โ)โ:
Then your Mapper could be configured like this:
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)
โ05-31-2023 12:08 PM
@rsramkoski thank you! it worked!