Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhooks coming in with application/xml in the Accept header #909

Closed
agrobbin opened this issue Jul 15, 2022 · 5 comments
Closed

Webhooks coming in with application/xml in the Accept header #909

agrobbin opened this issue Jul 15, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@agrobbin
Copy link

I wasn't sure where to put this issue, so if it should go to a different repo, or through a different channel from GitHub altogether, please let me know!

Issue

When testing out receiving webhooks in my Rails app, I was surprised by this output:

Processing by WebhooksController#create as XML

XML seemed like a very odd choice, but sure enough, when looking at the webhook request details coming in through the Stripe CLI w/ a debug log level (newlines/indentation added for readability):

[Thu, 14 Jul 2022 22:04:26 EDT] DEBUG websocket.Client.readPump: Incoming message message={
  "webhook_id":"1657850666-wh_L8j99zSNv0C4P2",
  "webhook_conversation_id":"1657850666-wc_EVSUDwjsgN4yhI",
  "event_payload":"[scrubbed]",
  "http_headers":{
    "Content-Type":"application/json; charset=utf-8",
    "Cache-Control":"no-cache",
    "User-Agent":"Stripe/1.0 (+https://stripe.com/docs/webhooks)",
    "Accept":"*/*; q=0.5, application/xml",
    "Stripe-Signature":"[scrubbed]"
  },
  "endpoint":{"api_version":"2020-08-27"},
  "type":"webhook_event"
}

Rails is doing the right thing, based on the Accept header being sent with the webhook request.

Expected Behavior

I would have expected the Accept header to at the very least prefer application/json, or leave it as simply */*. Seeing application/xml definitely caught me by surprise.

@agrobbin agrobbin added the bug Something isn't working label Jul 15, 2022
@gracegoo-stripe
Copy link
Contributor

@agrobbin, thanks for reporting the issue! We just deployed a change to update the Accept headers to */*.

@agrobbin
Copy link
Author

That's great to hear @gracegoo-stripe! I just tested it out, and it looks much less confusing. 😆

Stripe CLI:

"Accept":"*/*"

Rails server output:

Processing by WebhooksController#create as */*

@wezm
Copy link

wezm commented Dec 28, 2022

I was doing some testing of my webhooks implementation yesterday (with test/non-production keys, API version 2022-11-15) and it appears the Accept: */*; q=0.5, application/xml header is back. It tripped up my implementation, which is a bug on my side but it's still surprising that the webhook request indicates that it accepts XML (in addition to */*).

@nandueverurs
Copy link

Hi team,
I am facing the same issue with ACCEPT headers sent as XML from stripe webhook. I am using the latest API version and stripe gem installed in our project is 5.55 . Please let me know if I need to do any upgrades . Thanks in advance.

@solracdelsol
Copy link

solracdelsol commented Jan 29, 2024

I am also having the same issue while integrating Stripe Connect Express. The webhook is being processed as XML by the server instead of JSON for the account creation and linking with the Ruby on Rails SDK. Please help! The stripe SDK is 10.6.0

Update - figured it out, for future readers going through the same issue, adding both headers helped to send the json data as parseable HTML instead of unparseable XML. From your local logs, you can see the data is JSON but I am assuming at least Ruby on Rails can't recognize it? Hope this helps!

-H "Accept:/"
-H "Content-Type: application/json"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants