#Naveen H Y
1 messages · Page 1 of 1 (latest)
hi! our API does not accept JSON. For the other error, I think I need more information to debug that
do you have more context on what exact call you're making and what code you're using? Why don't you use one our official libraries instead of writing the raw HTTP request? https://stripe.com/docs/libraries
req_xMolcSYSqaiF14
actually I need to create a custom API in dynamics 365 where your libraries doesn't support that's the reason I'm going with HTTP call
@echo citrus This is the code which I'm trying to send request
does https://github.com/stripe/stripe-dotnet/ not work in that environment?
I'd suggest adding a log to see what exact value encodedData has before making the request, to start debugging it
encoded data I can see but the error is Invalid request: unsupported Content-Type text/plain; charset=utf-8"
it should be application/x-www-form-urlencoded .
I'm giving same header only
what does that mean?
I'm sending application/x-www-form-urlencoded header in the request
so when you run that code what happens?
IMO the problem is you're using StringContent so it will send a plain string
it throwns an error saying
{
"error": {
"message": "Invalid request: unsupported Content-Type text/plain; charset=utf-8. If error persists and you need assistance, please contact support at https://support.stripe.com/contact/.",
"type": "invalid_request_error"
}
}
you should be using FormUrlEncodedContent directly , like how this example works : https://stackoverflow.com/a/50942520/9769731 instead of converting it back to a string in your httpContent variable as you do in that code
HttpResponseMessage response = client.PostAsync(url, new FormUrlEncodedContent(postData)).Result; something like that.
ok let me try
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
yep, error message is clear I think
I'm able to hit the api but getting error
did you have a question about the error? you should be able to see the problem and fix it easily.
yes
but I'm sending payment method collection but it is throwing error as {
"error": {
"message": "Invalid payment_method_collection: must be one of always or if_required",
"param": "payment_method_collection",
👋 taking over for my colleague. Let me catch up.
the problem as stated in the error is with the payment_method_collection
the value is if_required and not if required
it's an enum, you can't just input any string
sure