manu avatar image
manu asked manu commented

Getting 401 message while trying to connect to API to GET inventory


I am trying to connect to my Web API to GET inventory.

I am using java to write code on my local computer to connect to my API. I have a Merchant ID and Access Token generated by going into "Setup" -> API Tokens -> Generate Token and I also checked permissions for 'Inventory' and 'Orders' for 'Read' and 'Write'

The URL I'm using is hereI am using the one in the curl command https:// api. clover. com /v3 / merchants/ [Merchant ID]/items?access_token=[API Token] and putted my Merchant ID and access token.

But I'm getting the following response from server :

Exception: Server returned HTTP response code: 401 for URL:[...

Message: Server returned HTTP response code: 401 for URL:[...

I am simply trying to GET inventory data using JAVA

Will appreciate your help.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jacob Abrams avatar image
Jacob Abrams answered manu commented

Are you using the same merchant id that appears in your browser when you went to "Setup > API Tokens"? You didn't leave in the square brackets in the URL correct? Here is an example (I changed the access token so it isn't my real access token):

Are you trying to do this on our production server and not sandbox? You might want to use for testing instead.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you Jacob,

The url was not correct, I used the one you mentioned and it works . :)

0 Likes 0 ·

I have 2 accounts. one is developer account on clover . com and I have Merchant ID and generated Access Token for that account. And imported Inventory excel file into it. I can successfully call GET on this account and get the response back as raw json inventory data.

My 2nd account is on sandbox. dev. clover. com with Merchant ID, access token for this account too and imported Inventory. But when I try to call GET on this account for inventory items I'm getting 401 error.

Can you explain whats the difference between them? Can I use the 1st account which is on clover . com for testing

0 Likes 0 ·

So they are two different server environments. Prod is what real merchants use and sandbox is where developers can test things in a more isolated environment. You can go ahead and use the prod account, but if you want to develop on a devkit device you must use sandbox. When you try calling GET on sandbox are you use the sandbox URL

0 Likes 0 ·

Yes Im using the apisandbox. dev URL and now getting Connection time out error.";

But on my real Merchant Account which is in use in our location. Im getting 401 error if I try to access production server.

To make things more clear. I have 3 accounts. 1. My original Merchant Account which is in production. : Getting 401 error 2. Sandbox development accont. : Getting connection time out error 3. Development account which I created on . This works fine

0 Likes 0 ·

Hmm, timeout is strange, you have a good internet connection? For each account you will have a different API token that only works with the merchant it was created for and the server that merchant is on.

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community