Struggling to return successful API requests

I’ve been reading over the API documentation extensively and can’t seem to make a successful API request. I am using reqbin.com to test it out, but to no avail and each request returns a 401 (unauthorized) error.

With this sample curl request from the documentation I replace YOUR_SECRET_API_KEY with my secret key.

curl -H "Accept: application/json" \
  https://app.snipcart.com/api/orders \
  -u {YOUR_SECRET_API_KEY}:

I’m not particularly knowledgeable about curl requests. Is there something painfully obvious I’m missing?

Hey @bugsysailor

I have a working application and I haven’t been able to get the curl command to work the way it’s laid out in the docs either.

However, I was able to get curl to work by encoding the Secret API Key in base 64 and doing this:

curl -H "Accept: application/json" \
    -H "Authorization: Basic BASE64_ENCODED_SECRET_API_KEY"
    https://app.snipcart.com/api/orders
2 Likes

This helps tremendously. Thank you.

Hey @bugsysailor ,

The -u or --user option in curl is by default a shortcut for setting the Authorization header with basic authentication (like @TorchlightPress reply demonstrated).

As for Reqbin, it looks like this option is not supported on their curl tool.

1 Like

hi, I am not able to make it work.

I try to connect my Snipcart with Jekyll to get stock level to showcase on my website but do not know how to implement the API.

can someone help me. thanks

I have tried everthing writen in this thread in Postman and in my terminal but…nothing

Hi @Geoffreyn can you give us more details of what exactly you’re struggling with?

Fell free to open a new question.

Thanks!

Hey Everyone,

I’m in the same boat. I cannot seem to get SnipCart to recognize my cURL requests. I’ve been trying to be able to issue refunds from my app using the API, but it just doesn’t work.

Is there a way to send POST requests via a webform or Ajax, instead of cURL?