Troubleshooting

Troubleshooting Common Square API Problems

Look up solutions to problems common across Square APIs and SDKs. For product-specific troubleshooting tips, see the product specific troubleshooting guide.

General problems
Permalink Get a link to this section

My call returns an EXPECTED_INTEGER error code.
Permalink Get a link to this section

Cause:

The EXPECTED_INTEGER error code means Square was expecting information as an integer but was sent something else (for example, a string or a float). The most common cause is a Money object with an invalid amount value.

Solution:

  • Make sure the amount value is specified in in the smallest denomination of the currency used. For example, the smallest currency denomination for USD is pennies.

  • Make sure the amount value is specified as a positive integer number.

  • Make sure the amount value is greater than, or equal to, the valid minimum amount.Valid minimums are determined by the Location.country associated with the account:

    • United States and Canadaamount values must be integers greater than, or equal to, 1.

    • Australia, Japan, and the United Kingdomamount values must be integers greater than, or equal to, 100.

Read more about working with monetary amounts.

Python errors while parsing with ValueError: No JSON object could be decoded
Permalink Get a link to this section

Cause:

Your client library does not chunk decode the JSON response. Square API endpoints return responses in a Transfer-Encoding: chunked format. Many libraries, including our Connect SDKs, will handle the decoding automatically for you. However, the Python httplib library and most native JSON libraries return the raw chunked request body.

Solution:

  • We strongly recommend you install and develop using our Connect SDKs. These SDKs add a helper wrapper that make it easier to integrate with Connect APIs.

  • If you do not use our SDKs, you can verify chunk encoding by checking the response for the Transfer-Encoding header. Alternatively, you can also examine the response body. If it alternates lines of hexadecimal numbers and JSON text, then the response is chunked. Learn more about Transfer-Encoding.

My resource update call returns an VERSION_MISMATCH error code.
Permalink Get a link to this section

A 400 Bad Request response is returned when an update is attempted with a stale resource.

"errors": [
  {
    "code": "VERSION_MISMATCH",
    "detail": "The version of the resource on the server does not match
               the version provided with the request. Please re-fetch the resource
              and try again.",
    "field": "version",
    "category": "INVALID_REQUEST_ERROR"
  }
]

Cause

After the local client endpoint got the resource to update, another client endpoint has written an update to this resource which incremented the resource version, making the local resource version stale.

Solution

Get the current version of the resource, update it, and try the update operation again.

Authentication problems
Permalink Get a link to this section

My API call returns an AUTHENTICATION_ERROR error code.
Permalink Get a link to this section

Cause:

Authorization errors are typically caused by typos or mismatched credentials.

Solution:

  • Make sure you have replaced placeholders and default values in sample code with valid application credentials.

  • Make sure you have configured your credentials correctly. For example, if you are testing calls in production, make sure you are not using sandbox credentials.

  • Make sure you are using the right credential type. For example, application IDs are used for OAuth API calls but Access Tokens are used in Payments API calls.

  • If you are using SqPaymentForm to generate a credit card nonce, make sure the credentials you use in your sqpaymentform.js file match the credentials you use for API calls that use that nonce.

  • For REST calls, make sure you have set the Authorization header key to "Bearer" and a valid access token.

Note: Older APIs sometimes refer to the application ID as a client ID (client_id) .