Why Does My Pipedream Workflow Return HTML Instead of JSON and How Can I Fix This?

This topic was automatically generated from Slack. You can find the original thread here.

Hi everyone**, I’m running into an issue with a Pipedream workflow that should return JSON but keeps returning HTML instead.**

Here’s what I’m doing:
• I’m receiving a form submission via webhook (email + password)
• Then I generate a UUID in a code step and pass it along
• I save the record to Airtable
• Then I call Stripe to create a Checkout Session via custom_request1, passing the UUID into metadata[uuid]
• Finally, in the Return_Checkout_stripe_link step, I want to return the Checkout URL in JSON like this:

js
return {
  statusCode: 200,
  headers: {
    "Access-Control-Allow-Origin": "*",
    "Content-Type": "application/json"
  },
  body: {
    checkout_url: steps.custom_request1.$return_value.url
  }
};

:white_check_mark: Stripe session is being created successfully
:no_entry_sign: But the response still returns HTML (like
<p><b>Success!</b></p>) — which crashes my frontend with a SyntaxError: Unexpected token '<' when trying to await response.json() on the redirect page.
Is there something I’m missing in the way I’ve configured the final return step? How do I make sure the webhook sends clean JSON back to my frontend?

Hey , could you try

  1. Set your HTTP trigger to returns Custom Response (image below)
  2. Then add this HTTP - Response with HTTP action to your workflow (maybe at the end)

thank you so much. This looks like what we are missing. I’m getting back now:

The end goal is to submit the form successfully, send data to the webhook & upon redirect, populate the stripe checkout session.

Can you tell me if my body is correct or am I missing something in terms of the headers?

Hey , your settings (1st image) seems fine to me. For your 2nd image of an error, I’m not sure where it’s coming from

Sorry, that’s coming from wordpress elementor forms.

It is form the first step in getting data, then on the seond step is where we need the webhook to return the stripe checkout session It is failing.

Hey , unfortunately Pipedream doesn’t have control over your Wordpress elementor, hence, we do not now why it is failing with that error, and we can not resolve it on Pipedream side.

I would recommend you to manually test your workflow to see if the webhook returns valid JSON with the valud stripe checkout_url

I understand that, the webhook does not return valid JSON with the url. That is ultimately the problem. Pipedream isn’t sending the format required, only html it appears.

, please see example in my template workflow here Sign Up - Pipedream.

I tested and it works on my side ( see images below )

I really appreciate this, I edited my body in the http return to meet yours with my own values… the webhook is still failing. I thank you for trying to help me with this.