Skip to main content

What is the best way to get this json response into a format for my next zap?

Right now i am getting back a jsob blob that looks something like 

 

I want to take this info coming from my webhook response and map the fields into an Action for a CRM, but i can’t figure out a way to easily transform that info format wise.  

Hi @hannah L 

Good question.

Try using a Code step to parse the JSON.

 


thanks @Troy Tessalone ! I tried that but i am getting .

SyntaxError: Unexpected token u in JSON at position 0” as an error 

I should also note that in the input data, i am using the “Raw Body” from my webhook zap.


@hannah L 

We’d need to see detailed screenshots with how your Zap steps are configured, thanks.


ok! here are the screenshots 

 


Hi @hannah L 

Try adding .trim() after the inputData.RAW to get inputData.RAW.trim()


Now getting this : 

TypeError: Cannot read property 'trim' of undefined


@hannah L 

That error makes it should like the mapped variable had “No data”.

Please post screenshots of your encountered error message.


 


@hannah L 

Ok, go head and remove the .trim().

Please post the other encountered error message after testing.


I really appreciate the help!


@hannah L 

Please clarify what Formatter action is being used in Step 2


 


@hannah L 

This help article explains the error: https://itsjavascript.com/unexpected-token-u-in-json-at-position-0

It means the JSON would have to be handled/prepped in the Code step before trying to pass it to the JSON.parse() method.

It may be related to this parameter for which the value doesn’t have the double quotes.

 


Okay, if i cant change that do you have any other suggestions to recommendations for how to get to the end result being “formatting this data so that i can send it to another app”?


@hannah L 

What data from the JSON do you need parsed out to use in other Zap steps?


Essentially the entire “raw body” , we want to use to send to a crm for example: {"ContactId":1701,"LoanId:2551","LoanUrl":"https://my.dev.xx.tech/loan?xxx",LoanId":"xx","RefId":"xx","FirstName":"John","LastName":"Homeowner","Email":"john.xx.3.10.2023.1007a@test.xx.com",”

I would want to come out like:

  • Contactid: 1701
  • LoanId: 2251
  • LoanUrl: 
  • Firstname: xx
  • LastName: xx
  • Email: xx

@hannah L

It’s possible with Code, but it means the JSON would have to be handled/prepped in the Code step before trying to pass it to the JSON.parse() method.

If you need help, consider hiring a Certified Zapier Expert: https://zapier.com/experts/automation-ace