Skip to main content

How do you properly pass dynamic data into the JSON body of a custom webhook?

Every time I try, I get an error “We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly.” If I run the scenario and test the input with JSONLint, it comes back as valid JSON. If I copy the JSON without variable data into the webhook body, the action works. 

I have tried using a formatter step to put all of the JSON into one variable that I then pass through. That still does not work. 

Here’s an example, if I type this directly, then the action step works.

{
"model": "gpt-3.5-turbo",
"messages": e{
"role": "user",
"content": "Please draft a concise email. Email Ashley about buying tickets to the conference on Friday."
}],
"temperature": 0.7
}

 

If instead I use a variable, then it doesn’t.

{
"model": "gpt-3.5-turbo",
"messages": {
"role": "user",
"content": "Please draft a concise email. {{187961999__output}}"
}],
"temperature": 0.7
}

 

Hi @CarlL

Good question.

Is there a reason you are trying to use the OpenAI via a Webhook vs using the OpenAI or ChatGPT Zap apps?

OpenAI: https://zapier.com/apps/openai/integrations#triggers-and-actions

ChatGPT: https://zapier.com/apps/chatgpt/integrations#triggers-and-actions

 

We’d need to see detailed screenshots with how your Zap steps are configured in order to properly review.


No reason more than I should be able to and it’s an example of JSON error I get anytime I use dynamic data in the request, not just for OpenAI. I assume that there’s a method to passing dynamic data into the JSON that I’ve not been able to find. Here are screenshots. One removes new lines so that the text goes into the JSON correctly.


@CarlL 

Make sure to remove leading/extra/trailing whitespace in the JSON data.


I’ve done that as well. I can copy the input value from the failed step and check it with JSONLint. It is valid JSON.


@CarlL 

I tested successfully with this POST Webhook config.

 

 


What’s the code step you’re using? I had used formatter to remove line breaks of the original input.