#Naveen H Y

1 messages · Page 1 of 1 (latest)

stark etherBOT
echo citrus
#

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

eager raven
#

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

echo citrus
echo citrus
# eager raven

I'd suggest adding a log to see what exact value encodedData has before making the request, to start debugging it

eager raven
#

encoded data I can see but the error is Invalid request: unsupported Content-Type text/plain; charset=utf-8"

echo citrus
#

it should be application/x-www-form-urlencoded .

eager raven
#

I'm giving same header only

echo citrus
#

what does that mean?

eager raven
#

I'm sending application/x-www-form-urlencoded header in the request

echo citrus
#

show me the exact code you're using

#

@eager raven still there?

eager raven
#

yes

#

you need actual code?

echo citrus
#

so when you run that code what happens?

#

IMO the problem is you're using StringContent so it will send a plain string

eager raven
#

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"
}
}

echo citrus
#

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.

eager raven
#

ok let me try

stark etherBOT
echo citrus
#

yep, error message is clear I think

eager raven
#

I'm able to hit the api but getting error

echo citrus
#

did you have a question about the error? you should be able to see the problem and fix it easily.

eager raven
#

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",

fierce crane
#

👋 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

eager raven
#

ok

#

Yes its working now

fierce crane
#

perfect

#

let me know if you need any more help

eager raven
#

sure