Getting Error while Sending API request in Thunkable

Hi There!

I’m Getting Error while Sending an API Request even after Sending same Request in Postman in Which I got Correct Response
Please Help

Postman Request:




Blocks:

Error Response:
gsdfgAf

Thanks, whoocoder

Try removing the “generate JSON from object” from the Web_API Body block.

1 Like

Hi Steve!

I removed generate JSON block from Body o Web API but No Response was Being Shown.
image

Change your content type to application/json in the header

Format it as a proper Json object using list blocks with nested objects

1 Like

Can you Please send me the Bolcks so that I can Format the Body in List Format??

No :rofl:

Please try first. At least show that you’re putting forth the effort to implement my feedback.

Post a new block example where you try to interpret what I meant.

1 Like

Additionally, if you need that key to be private, you should do this call from a backend server. While you can do it from the client doesn’t make it a best or even safe practice.

Just something to think about

1 Like

In Postman, you are sending in the x-www-form-urlencoded method in thunkable you are sending in JSON format. So just like @jared mentioned, set your Content-Type header to application/json. If it still doesn’t work then try adding these headers:

-H 'Accept-Encoding:gzip,deflate,br'
-h 'Accept:*/*'
1 Like

image
image
Still error

1 Like

Try setting the content-type header to x-www-form-urlencoded again, Set Accept to */*. If it still doesn’t work try removing some headers except content-type

1 Like

image
Still Error
[
image

pleaes show more of your blocks here

all of the api blocks, preferably

URL
body
query
headers

1 Like

Check this related solution from @muneer

1 Like

I Used Xano Backend Server for API Request and Now It’s Working!

2 Likes

nice!

yeah, i always forget that the x-www-form-urlencoded needs to go in the body as text

Sorry but glad you got it working! you should share a screenshot or screen recording of the api call in xano for others to see the solution! :slight_smile:

1 Like

Hi Jared!

Sorry for the Late Reply :sweat_smile:

image

Response:

{
request: {
url: https://api.stripe.com/v1/checkout/sessions,
method: POST,
headers: [
POST /v1/checkout/sessions HTTP/2,
Host: api.stripe.com,
accept-encoding: gzip, deflate,
authorization: Basic API KEY,
content-type: application/x-www-form-urlencoded,
accept: application/json,
content-length: 214],
params: {
success_url: https://thunkable.site/w/********************,
line_items[0][price]: price_*****************************,
line_items[0][quantity]: 1,
mode: subscription,
discounts[][coupon: sq***********}},
response: {
headers: [
HTTP/2 200,
server: nginx,
date: Mon, 30 Oct 2023 02:08:46 GMT,
content-type: application/json,
content-length: 2099,
access-control-allow-credentials: true,
access-control-allow-methods: GET,HEAD,PUT,PATCH,POST,DELETE,
access-control-allow-origin: *,
access-control-expose-headers: Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required,
access-control-max-age: 300,
... +10 more
],
result: {
id: cs_live_****************************************************************************,
object: checkout.session,
after_expiration: null,
allow_promotion_codes: null,
amount_subtotal: ******,
amount_total: *****,
automatic_tax: {
enabled: false,
status: null},
billing_address_collection: null,
cancel_url: null,
client_reference_id: null,
client_secret: null,
consent: null,
consent_collection: null,
created: ********,
currency: inr,
currency_conversion: null,
custom_fields: [],
custom_text: {
shipping_address: null,
submit: null,
terms_of_service_acceptance: null},
customer: null,
customer_creation: always,
customer_details: null,
customer_email: null,
expires_at: &****&****,
invoice: null,
invoice_creation: null,
livemode: true,
locale: null,
metadata: {},
mode: subscription,
payment_intent: null,
payment_link: null,
payment_method_collection: always,
payment_method_configuration_details: {
id: pmc_**********************************************,
parent: null},
payment_method_options: null,
payment_method_types: [
card],
payment_status: unpaid,
phone_number_collection: {
enabled: false},
recovered_from: null,
setup_intent: null,
shipping_address_collection: null,
shipping_cost: null,
shipping_details: null,
shipping_options: [],
status: open,
submit_type: null,
subscription: null,
success_url: https://thunkable.site/w/***************************************,
total_details: {
amount_discount: *******************,
amount_shipping: 0,
amount_tax: 0},
ui_mode: hosted,
url: https://checkout.stripe.com/c/pay/cs_live_*********************************************************************************************************************************************************************************************************************************************************************************************************************************************************},
status: 200}}
2 Likes

nice work!!

2 Likes