Does Pipedream Proxy Have an Issue with Non-JSON Payloads, as Evidenced by Stripe 400 Error Responses?

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

Hello, any chance Pipedream proxy has an issue with non-JSON payloads? Proxied Airtable requests work all good for me and they are JSON based but with Stripe I keep hitting 400. It requires application/x-www-form-urlencoded.

code:

const pdResponse = await pd.makeProxyRequest(
    {
      searchParams: { external_user_id: externalUserId, account_id: accountId },
    },
    {
      url: STRIPE_WEBHOOK_ENDPOINT,
      options: {
        method: "POST",
        headers: { "Content-Type": "application/x-www-form-urlencoded" },
        body: params.toString(),
      },
    },
  );

data:

{
  searchParams: {
    external_user_id: 'c6a0c******-******',
    account_id: 'apn_*****'
  }
} {
  url: 'https://api.stripe.com/v1/webhook_endpoints',
  options: {
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    body: 'url=https%3A%2F%2Fsupabase-pipedream.netlify.app%2Fstripe-invoice-updated&description=Stripe+webhook+for+invoice+sync+activation&enabled_events%5B%5D=invoice.created&enabled_events%5B%5D=invoice.updated&enabled_events%5B%5D=invoice.payment_failed'
  }
}

response is

HTTP error! status: 400, body: {"error":"bad request: check parameters"}

Which is vague and I suspect Stripe couldn’t figure out the body as a whole, but I’m not sure, maybe Stripe would respond vaguely even in case of a minor mistake.

Also maybe in this case instead of creating a webhook via API I could do pd.deployTrigger right?

This is what I need:

Can you try pre-prending the Content-Type with x-pd-proxy-? That’s required in order to send it in the request from the Connect Proxy to Stripe. So,

...headers: { "x-pd-proxy-Content-Type": "application/x-www-form-urlencoded" },...

And also yea, you probably should just use pd.deployTrigger, exactly. I guess either works, but our prebuilt trigger might have some additional logic over just the raw webhook in Stripe, but I’m not positive in that case. Might be very similar to use either approach.

ah, x-pd-proxy- prefix did not help but I’m gonna go ahead and try pd.deployTrigger. In case of stripe it’s likely not a big difference but I was also going to register webhooks for Airtable and there I would have to periodically refresh them because they expire. So for airtable webhooks pd.deployTrigger will save me work for sure.