Best answer

How to make custom Zapier Integration Step (built with Platform UI) return raw JSON

  • 16 September 2023
  • 1 reply
  • 79 views

Userlevel 1

Hi Community,

 

I am building an automation that takes information (hotel bookings, including guest data) from one API (hotel management software) to another (reporting tool).

I normally would use catch hook by Zapier, but I had to create a custom integration with the Platform UI because the API I used required digest auth method.

The response includes a json with multiple guest’s details, please see below the sample with two guests’ details:
 

[
{
"id": 9750986,
"booking_id": 8200527,
"guest_id": 26782487,
"registration_card_number": null,
"created_at": "2020-07-10T11:26:11.608Z",
"updated_at": "2020-07-10T11:26:11.608Z",
"registration_card": true,
"verified_at": null,
"verified_by_id": null,
"signature_id": null,
"guest": {
"language": null,
"accept_marketing_emails": false,
"created_at": "2020-07-10T11:26:11.090Z",
"updated_at": "2020-07-10T11:26:11.090Z",
"person_title_id": null,
"family_id": 26782488,
"accompany": null,
"address": null,
"age": null,
"birth_city": null,
"birth_country": null,
"birth_date": null,
"car": null,
"car_number": null,
"checkpoint_date": null,
"checkpoint_name": null,
"city": null,
"country": null,
"document_expire_date": null,
"document_issue_date": null,
"document_issued_by": null,
"document_number": null,
"document_type": null,
"e_mail": null,
"fax_number": null,
"first_name": "George",
"gender_code": null,
"last_name": "Smith",
"level": null,
"middle_name": null,
"next_destiantion": null,
"notes": null,
"person_id": null,
"phone_number": null,
"state": null,
"visa_expire_date": null,
"visa_issue_date": null,
"visa_type": null,
"visit_purpose": null,
"workplace_company": null,
"workplace_position": null,
"zip_code": null
}
},
{
"id": 9750987,
"booking_id": 8200527,
"guest_id": 26782488,
"registration_card_number": null,
"created_at": "2020-07-10T11:26:11.679Z",
"updated_at": "2020-07-10T11:26:11.679Z",
"registration_card": true,
"verified_at": null,
"verified_by_id": null,
"signature_id": null,
"guest": {
"language": null,
"accept_marketing_emails": false,
"created_at": "2020-07-10T11:26:11.642Z",
"updated_at": "2020-07-10T11:26:11.642Z",
"person_title_id": null,
"family_id": 26782488,
"accompany": null,
"address": null,
"age": 23,
"birth_city": null,
"birth_country": null,
"birth_date": null,
"car": null,
"car_number": null,
"checkpoint_date": null,
"checkpoint_name": null,
"city": null,
"country": null,
"document_expire_date": null,
"document_issue_date": null,
"document_issued_by": null,
"document_number": null,
"document_type": null,
"e_mail": null,
"fax_number": null,
"first_name": "George",
"gender_code": null,
"last_name": "Smith",
"level": null,
"middle_name": null,
"next_destiantion": null,
"notes": null,
"person_id": null,
"phone_number": null,
"state": null,
"visa_expire_date": null,
"visa_issue_date": null,
"visa_type": null,
"visit_purpose": null,
"workplace_company": null,
"workplace_position": null,
"zip_code": null
}
}
]

Now, my problem is that despite the response looks good upon testing, in the subsequent steps Zapier steps, the raw JSON is not available to select. This is a problem because I would like to take the JSON and further process it in the subsequent step. See screenshots:

This means that I would need to add each field one by one in the subsequent steps, which would not work for our purposes, as the number or guests in bookings varies.


Does anyone have an idea how to deal with this best?

 

When I overcome this problem I plan to use Looping by Zapier to send each guests’ details to the other tools API.

 

icon

Best answer by connorz 18 September 2023, 15:30

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.

1 reply

Userlevel 3
Badge +6

Hey @ZAPit ,

Have you explored stringifying the response and returning that from the trigger or action as a property value?

For example, in the truncated example below, I’m using code mode to return an object from the action. That object has one property, “json,” whose value is the stringified response.

...

return z.request(options)
.then((response) => {
response.throwForStatus();

return {
json: JSON.stringify(response.json)
}
});

That should output the response data as a string, which you could then parse that in a Code by Zapier step: