Stripe API documentation commands returning errors

I am reading Stripe’s api documentation and trying out the curl commands (https://stripe.com/docs/api/customers/update). I created an account with Stripe and am running the commands in the test mode using my secret_key. I get the error below when I run the command.

`curl https://api.stripe.com/v1/customers/cus_NC2tFwyzx3A4mM \
  -u sk_test_my_test_key: \
  -d "metadata[order_id]"=6735

`

{ "error": { "code": "resource_missing", "doc_url":
"https://stripe.com/docs/error-codes/resource-missing", "message": "No
such customer: ‘cus_NC2tFwyzx3A4mM’", "param": "id",
"request_log_url": "https://dashboard.stripe.com/test/logs/…",
"type": "invalid_request_error" } }

I am not quite sure what I am missing. I tried the steps mentioned, created an account and used the test key. Can someone let me know what I am missing here?

>Solution :

That error message indicates that there is no Customer with that specific customer id anywhere in your Stripe account. This is just an example request and it’s possible the id is random if you don’t have a real Customer in your account.
You should first create a Customer (via the Dashboard or the API) and then use that real Customer id to update it afterwards by changing the id in the URL you use in curl.

I highly recommend sidestepping curl entirely and starting to write real code in your favorite language using one of Stripe’s official client libraries. Their quickstart helps you get to a running example quickly and makes it easier to iterate on their API fairly simply afterwards.

Leave a Reply