Best answer

Processing dynamic json data in trigger

  • 27 November 2021
  • 4 replies
  • 325 views

I am integrating my API with Zapier and I am faced with a trouble. I am sending data from API in this format:

{
"email": "player@domain.com",
"phoneNumber": "+380991234567",
"fullName": "John Doe",
"termsAccepted": true,
"extra": "{\"city\":\"New York\", \"hobby\":\"music\"}",
"campaignId": 1,
"createdAt": "2021-03-16T12:36:44.595Z",
"updatedAt": "2021-06-24T21:18:47.871Z"
}

Every time API send extra field with different structure. For next request data can be in another format:

{
"email": "player@domain.com",
"phoneNumber": "+380991234567",
"fullName": "John Doe",
"termsAccepted": true,
"extra": "{\"car\":\"Audi\", \"country\":\"USA\"}",
"campaignId": 1,
"createdAt": "2021-03-16T12:36:44.595Z",
"updatedAt": "2021-06-24T21:18:47.871Z"
}

For the trigger, I added user input data to choose the fields to process from the extra field, but I don't understand how to use fields from json in next steps

icon

Best answer by Zane 29 November 2021, 16:34

View original

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

4 replies

The structure of the extra field will vary for different campaigns. I am getting a list of fields for extra from the API, but I don't understand how to add these fields to the output data. I tried adding these fields for the PerformList response, but it didn't help. Extra fields were available, but after processing the event extra fields were empty. I added code for processing Perform:

 return [{ ...bundle.cleanedRequest, ...bundle.cleanedRequest.extra }];

I did a Gmail integration, checked the Zap history and saw this result:

 

 

I expect to see data from country field, but got 139225185__country

I would be grateful for any help @Zane 

Userlevel 7
Badge +9

 

Your Zap editor message says ‘county’, not ‘country’. Did you perhaps map the wrong field? That’s the first thing I’d look at. 

A general statement about custom fields (you may have sorted this out already, but for others reading this):

The country field needs to be mapped explicitly in the Zap editor. Zap steps only have access to data the user chooses to make available. 

While Zapier supports custom/user-defined fields (where a user sees fields in their result that other users don’t see) it is still expected that each response for that Zap instance is consistent with sample that the user used to map their fields in the Zap editor.  So if fields in the result are changing from response to response to a given Zap instance, it’s not going to work well with Zapier. You’ll probably want to have them choose a specific campaign, and have a single trigger instance only work with that data, so that the shape and content of the data is completely consistent from response to response. 

 

You're right. I just had a typo :(