Closed wezm closed 1 year ago
In your point 2, adding accepted_formats [:xml]
to ApiAction
is definitely necessary. Each action needs to know which mime types are allowed, and default is :json
, so for an XML based API, you'd have to specify.
But I do think there may be some issues around using *
in Accept headers. I had an issue before when just using cURL related to this.
In your point 2, adding accepted_formats [:xml] to ApiAction is definitely necessary. Each action needs to know which mime types are allowed, and default is :json, so for an XML based API, you'd have to specify.
Ahh yes, perhaps I wasn't clear. The Stripe API is completely JSON based, at least that's what is documented. There's no XML involved in what I'm doing. I'm not sure why their request indicates they accept XML.
I'd be curious to know... is that a bug in their postback API? That seems pretty strange if it's a JSON API, but their API sends an Accept header with "application/xml" in it :joy: maybe it's meant to be a fallback? :man_shrugging:
Weirdly enough it was reported and apparently fixed in July but appears to have returned... https://github.com/stripe/stripe-cli/issues/909
Describe the bug
Lucky incorrectly rejects a request as not acceptable, even thought the
Accept
header has a*/*
entry.To Reproduce
ApiAction
Accept
header with this value:*/*; q=0.5, application/xml
Expected behavior
The request is handled.
Actual behaviour
The request is rejected with status 406 Not Acceptable. The error indicates that the client wants XML so this should be added to the accepted formats. However, this is not true the
*/*
entry means the client accepts anything, including the configured format,:json
.Versions (please complete the following information):
crystal --version
): Crystal 1.6.2Additional context
:xml
toaccepted_formats
allows working around the issue, but should not be necessary