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

Content-Type error from Stripe API #39

Closed
tarikstafford opened this issue May 11, 2018 · 12 comments
Closed

Content-Type error from Stripe API #39

tarikstafford opened this issue May 11, 2018 · 12 comments

Comments

@tarikstafford
Copy link

Hey guys,

Sorry to bother, another issue. I am getting an error response from the stripe API declaring a content-type error. Not sure what the issue is, will try and do some digging.

"Invalid request: unsupported Content-Type text/plain; charset=utf-8. If error persists and you need assistance, please contact support@stripe.com."
@Andrewangeta
Copy link
Member

What was the issue?

@tarikstafford
Copy link
Author

@Andrewangeta I still don't know. I am trying to solve it, but closed it till I do more digging.

@tarikstafford
Copy link
Author

@Andrewangeta did a fresh vapor proj to test it and it's also not working so it must be an issue with the new StripeRequest being sent to the StripeAPI.

@tarikstafford
Copy link
Author

@Andrewangeta

try body.encode(request)

this at least doesn't get an error but the content does not go through.

try request.content.encode(body, as: .urlEncodedForm)

@Andrewangeta
Copy link
Member

@tarikstafford I know the issue. Pushing a fix now.

@Andrewangeta
Copy link
Member

@tarikstafford 2.0.7 tag should fix the issue.

@anagpal1990
Copy link

Hi Team, did we get any fix to this issue, i'm still getting same error in response from API call from Stripe.

@anthonycastelli
Copy link
Member

@anuj-inecta What version of the provider are you running? This should of been resolved long ago.

@anagpal1990
Copy link

Hi @anthonycastelli , thanks for revert..
Actually, we got this issue while running the App Monetization code which integrates Dynamics 365 Business Central with Stripe. Same code was working fine earlier but suddenly it started giving this error.
Lucking, after some digging yesterday, i found one bug in the code for web request call and fixed the issue.

@mohsinJanjua
Copy link

Hi @anthonycastelli , thanks for revert..
Actually, we got this issue while running the App Monetization code which integrates Dynamics 365 Business Central with Stripe. Same code was working fine earlier but suddenly it started giving this error.
Lucking, after some digging yesterday, i found one bug in the code for web request call and fixed the issue.

Hi @anuj-inecta
I'm facing exactly same issue. the code for app monetization was working fine. then we upgraded to the October release of Business Central and it is now giving me this issue. Can you please tell me what exactly was the probelm? It will be a great help.
Thank you in advance.

@anagpal1990
Copy link

Hi @mohsinJanjua , there was a small bug in the code that i found.
If you see in Cod50298.StripeWebService.al, there is one line of code Arguments.SetRequestContent(RequestContent). Here it was called before setting Header "Content Type". So later, when If not CallWebService(Arguments) then is called, it didn't had the Content-Type set.
I also checked for API logs on stripe portal and it was sending blank JSON as request and was getting same error as mentioned above.
To fix this issue, i called Arguments.SetRequestContent(RequestContent) after adding request header.
Not sure, how it was working fine earlier but this fixed the issue for me.

Note - Above fix is required to be applied in all functions i.e CreateCustomer, UpdateCustomer, CreateSubscription etc.

image

@mohsinJanjua
Copy link

mohsinJanjua commented Nov 15, 2018

Hi @mohsinJanjua , there was a small bug in the code that i found.
If you see in Cod50298.StripeWebService.al, there is one line of code Arguments.SetRequestContent(RequestContent). Here it was called before setting Header "Content Type". So later, when If not CallWebService(Arguments) then is called, it didn't had the Content-Type set.
I also checked for API logs on stripe portal and it was sending blank JSON as request and was getting same error as mentioned above.
To fix this issue, i called Arguments.SetRequestContent(RequestContent) after adding request header.
Not sure, how it was working fine earlier but this fixed the issue for me.

Note - Above fix is required to be applied in all functions i.e CreateCustomer, UpdateCustomer, CreateSubscription etc.

image

Thanks a lot, @anuj-inecta :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants