Question

How to transform JSON response?

  • 11 February 2022
  • 13 replies
  • 5754 views

Userlevel 1
Badge

I am calling an API that produces a sizable JSON response. Zapier is trying to output most of the leaf nodes as values, but I want to just take the entire body into the next step. Is this possible?


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

13 replies

Userlevel 7
Badge +14

Hi @zap29550 

Try this configuration with 2 Zaps.

 

Zap 1

  1. Trigger: ???
  2. Action: YOUR API Request
  3. Action: Webhook - Custom Request (POST)

 

Zap 2

  1. Trigger: Webhook - Catch Raw Hook
  2. Action: ???

 

Userlevel 1
Badge

Sorry, not sure I follow. I have a Webhooks by Zapier - Custom Request which produces the lengthy response.

 

Can I just get the body raw?

Userlevel 7
Badge +14

@zap29550

Zapier automatically parses the JSON response from an API request.

So you’d need to use the above method to chain together Zaps in order to get the RAW JSON response from the API request.

Userlevel 1
Badge

@Troy Tessalone I appreciate the info. Trying to follow your above example, I have Zap 1 and Zap 2. Zap 1 is triggered by a webhook. I have a webhook URL for Zap 2. Can you help me understand how they’re “chained” together?

Userlevel 1
Badge

I was able to piece it together. You end the Zap with a Webhooks by Zapier - Custom Request which POST’s to the 2nd Zap’s Webhook. Thanks!

Userlevel 1
Badge

@Troy Tessalone I spoke too soon. The Zap 2 webhook is receiving a payload that’s not raw

{'data__item__uuid': '', 'data__item__parentUuid': '', 'data__item__uuidType': 'organization', 'data__item__personalize': True, 'data__item__title': 'test', 'data__item__internalTitle': 'test', 'data__item__description': '', 'data__item__type': 'standard'...

 

Userlevel 7
Badge +14

@zap29550 

Are you using this trigger for Zap 2: Catch Raw Hook

 

Example of how I have the Zaps configured...

Zap 1

 

Zap 2

 

Data from Zap 2 trigger with RAW Body in JSON format

 

Userlevel 1
Badge

Zap 1, step 5

Zap 1, stpe 6

 

Zap 2, step 1

 

Userlevel 7
Badge +14

@zap29550 

Your screenshot shows the JSON RAW data in the Zap 2 trigger, what are we missing?

 

Userlevel 1
Badge

@Troy Tessalone it’s flattened. The JSON response looks like:

https://uploads-us-west-2.insided.com/zapier-ca/attachment/e2b094ad-394c-4a00-8efb-909090ce459b.png

{
"data": {
"item": {
"uuid": "xxx",
"parentUuid": "",
"uuidType": "organization",
"personalize": true,
"title": "xxx",
"internalTitle": "xxx",
"description": "",
...

 

Userlevel 7
Badge +14

@zap29550 

Is the data not usable in the received format for Zap 2, Step 1?

 

May have to do with how the data is being returned from your Zap 1, Step 5.

The returned data from Zap 1, Step 5, is nested within a “data” (first screenshot below) that is then being sent in a “Data” object (second screenshot below) for Zap 1, Step 6, which may be causing the data to be manipulated.

 

 

May want to open a ticket with Zapier Support for further guidance: https://zapier.com/app/get-help

Userlevel 1
Badge

 

@zap29550

Is the data not usable in the received format for Zap 2, Step 1?

It is not. I need to get the same payload and send it to another API call.

 

Just opened a ticket.

Userlevel 7
Badge +12

Hi @zap29550 
Try this