question

jdahlennwi avatar image
jdahlennwi asked jdahlennwi published

Unable to create Tender via API

I'm attempting to create a Tender via REST API with the following request, but am receiving an error:

POST https://apisandbox.dev.clover.com/v3/merchants/{
                {merchant-id}}/tenders
Accept: */*
Cache-Control: no-cache
Authorization: Bearer {
                {oauth-token}}
Access-Control-Allow-Origin: *

{
  "tender":{
    "label":"my test tender",
    "enabled":true
  }
}

Here is the response:
HTTP/1.1 400 Bad Request
cache-control: no-cache, no-store, must-revalidate
pragma: no-cache
expires: Tue, 17 Sep 1991 10:00:00 PST
content-length: 54
content-type: application/json; charset=utf-8
X-Frame-Options: SAMEORIGIN
X-Robots-Tag: none


{
  "message": "Error inserting new tender into database"
}


Response code: 400 (Bad Request); Time: 379ms; Content length: 54 bytes
What is the cause for this? As you can see there is no helpful information in the response.
REST API
10 |2000

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

David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited
Sorry, I was using the V2 endpoint. I was able to reproduce the error you are seeing with the V3 endpoint. It looks like the "opensCashDrawer" property is required. Go ahead and set that and let me know. Obviously, this is inconsistent with our docs so I will create an internal issue to have someone look into it.
10 |2000

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

hergy80 avatar image
hergy80 answered
Generally a 400 bad request means you didn't supply all the necessary fields. You can see the error codes at: https://docs.clover.com/clover-platform/docs/400-bad-request. Make sure your merchant Id is correct and all required fields are sent.

10 |2000

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

David Marginian avatar image
David Marginian Deactivated answered jdahlennwi published
I just added a custom tender to my sandbox merchant using the same POST body as you via postman. Perhaps your POST headers are off?
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.

jdahlennwi avatar image jdahlennwi commented ·

I reduced my headers to the bare minimum(below) and the result is the same

POST https://apisandbox.dev.clover.com/v3/merchants/{
                   {merchant-id}}/tenders<br>Authorization: Bearer {
                   {oauth-token}}<br><br>{"tender":{"label":"test","enabled":true}}

response:

POST https://apisandbox.dev.clover.com/v3/merchants/{
                   {merchant-id}}/tenders


HTTP/1.1 400 Bad Request
cache-control: no-cache, no-store, must-revalidate
pragma: no-cache
expires: Tue, 17 Sep 1991 10:00:00 PST
content-length: 54
content-type: application/json; charset=utf-8
X-Frame-Options: SAMEORIGIN
X-Robots-Tag: none


{
  "message": "Error inserting new tender into database"
}


Response code: 400 (Bad Request); Time: 478ms; Content length: 54 bytes
<br>

I suspect nothing is wrong with my request, but someone about the sandbox environment, or my sandbox account. I even tried using curl via terminal:

curl -g -H "Authorization: Bearer <access token>" --header "Content-Type: application/json" --request POST -d '{"tender":{"label":"test","enabled":true}}' "https://apisandbox.dev.clover.com/v3/merchants/<merchant-id>/tenders"

with response:

{"message":"Error inserting new tender into database"}
0 Likes 0 ·

Welcome to the
Clover Developer Community