question

mohammed avatar image
mohammed asked Jacob Abrams commented

401 Unauthorized when creating a new Order Type

Hello,

I want to create a new OrderType using the API, but I'm getting the message "401 Unauthorized",

I sent a post request to the end point /v3/merchants/{mId}/order_types the JSON object is :

{
 "taxable": true,
"filterCategories":  false,
"label": "Test Order t",
"isHidden": true,
"isDefault":false,
"hoursAvailable": "BUSINESS"
 }

the token is valid because I can get the list of existing order types and the app has MERCHANT_W permission

Can someone please explain to me what's the problem

Orders
5 comments
10 |2000

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

Jacob Abrams avatar image Jacob Abrams ♦♦ commented ·

Can you follow the directions at https://docs.clover.com/build/web-app... and try using curl? If it doesn't work using curl run it with the -voption to make it verbose. Then post the results to a pastebin.com. Note this will expose your token so you might want to obscure some of the token characters before pasting it.

0 Likes 0 ·
mohammed avatar image mohammed commented ·

Thank you @jacobabrams for your response, this is the result of curl : http://pastebin.com/index/hwLU2c4Z .I got the same message

0 Likes 0 ·
Jacob Abrams avatar image Jacob Abrams ♦♦ commented ·

Are you writing an android app? If so how are you obtaining the auth token? Did you follow the instructions at: https://docs.clover.com/build/android-apps/samples/#querying-web-service

0 Likes 0 ·
mohammed avatar image mohammed commented ·

it's a web app

0 Likes 0 ·
josh avatar image josh commented ·

Hmm. Not sure what the problem is. You will want to add the header "Content-Type: Application/json" although that shouldn't throw an authorization error.

How did you generate the token?

0 Likes 0 ·
q-factor avatar image
q-factor answered mohammed commented

The end point is /v3/merchants/{mId}/order_types , if that's the issue.

1 comment
10 |2000

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

mohammed avatar image mohammed commented ·

Yes , I'm using this one

0 Likes 0 ·
mohammed avatar image
mohammed answered

still not working, any 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.

Jacob Abrams avatar image
Jacob Abrams answered mohammed commented

I checked your merchant C1VED12GRTQ3T and it doesn't have any API tokens in the Clover Setup web app. If you are building a web app that you plan to provide to other merchants you are most likely going to need to use oauth:

https://docs.clover.com/build/web-app...

Or you need to generate an API token for your particular merchant if that is all you care about:

https://help.clover.com/api-tokens/?u...

1 comment
10 |2000

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

mohammed avatar image mohammed commented ·

Yes i'm using the ouath, and my token is valid, I can get ordertypes, create order, get itmes.

0 Likes 0 ·

Welcome to the
Clover Developer Community