#Sonnyshot-OpenAPI

1 messages · Page 1 of 1 (latest)

nova roost
random marten
woeful acorn
#

the request and the response

#

and then one that works as was mentioned before

random marten
#

you will have to use different syntax for Postman

woeful acorn
#

but this is how i would expect to make the request

random marten
#

events_types[0] -> event type 1

#

events_types[1] -> event type 2

woeful acorn
#

i've also made the requests using javascript axios or python requests

#

is it not possible to have an array in the body like {"enabled_events":["invoice.created", "account.updated"]} ?

random marten
#

yeah, here you've selected URL-form-encoded type in which the syntax of passing the array parameter is

curl https://api.stripe.com/v1/webhook_endpoints \
  -u sk_test_xxxxx: \
  -d url="https://example.com/my/webhook/endpoint" \
  -d "enabled_events[]"="charge.failed" \
  -d "enabled_events[]"="charge.succeeded"
#

this will just be the syntax required

#

can you try add [] in the event_types in POSTMAN

#

and see if it works?

#

this works for me

woeful acorn
#

right, i get that that works, but I guess my question was more about the use of event_types as a property of type array in the OpenAPI spec

#

hmm that was not the formatting i was going for lol

nova roost
#

In languages like Python, you can use the regular syntax. For example

    stripe.WebhookEndpoint.create(
      url="https://example.com/my/webhook/endpoint",
      enabled_events=[
        "charge.failed",
        "charge.succeeded",
      ],
    )
#

javascript

  const webhookEndpoint = await stripe.webhookEndpoints.create({
    url: 'https://example.com/my/webhook/endpoint',
    enabled_events: [
      'charge.failed',
      'charge.succeeded',
    ],
  })
random marten
#

right, underneath it, the above was translated to an HTTP call with encoded with form-urlencoded format which is like this

  -d "enabled_events[]"="charge.failed" \
  -d "enabled_events[]"="charge.succeeded"

that is still an array, it is just a standard you will have to follow

woeful acorn
#

gotcha, so for form-urlencoded bodies, it has to be send in that way

#

i guess that was more of me not understanding the standard than a specific issue with Stripe but I appreciate the help all the same!

random marten
#

np good luck.