Suddenly getting internal server error on all create invoice requests

We have had an integration running for a year now, and have not made any changes, but suddenly we receive “Bad response to callout - code: 406 status: Not Acceptable body: HTTP/1.1 500 Internal Server Error” to all requests to the invoices API at (https://connect.squareup.com/v2/invoices). Example request is below. Is this a server side bug? It has been there for at least a couple days…

‘{’+
‘“invoice”: {’+
‘“order_id”: "’+OrderID+‘",’+
‘“title”: "’+WO.Subject.escapeJava()+‘",’+
‘“primary_recipient”: {’+
‘“customer_id”: "’+CustomerID+‘"’+
‘},’+
‘“payment_requests”: [’+
‘{’+
‘“request_type”: “BALANCE”,’+
‘“tipping_enabled”: false,’+
'“due_date”: “2022-08-17”+
‘}’+
‘],’+
‘“accepted_payment_methods”: {’+
‘“card”: true,’+
‘“bank_account”: false,’+
‘“square_gift_card”: false’+
‘},’+
‘“delivery_method”: “SHARE_MANUALLY”,’+
‘“location_id”: “F9VJIOF802HF83F”’
}
}

:wave: What’s the application ID that you’re getting this with? :slightly_smiling_face:

I don’t see anything called "application ID ", can you clarify?

If you go to your Developer Dashboard what the ID of the application that’s making the API calls. :slightly_smiling_face:

I see - it is sq0idp-fpKjF-5wPeo6PRyPXBjqVQ - why?

I took a look at your API Logs and I’m not seeing any 5xx errors. I do see a 406 error but no error message. I’m reaching out to the team about this. :slightly_smiling_face:

What’s the IP address that you’re using to make the requests from? :slightly_smiling_face:

Take a look at my original message - it is returning a 406 error, but the body of the error message says “500 internal server error”, so it is doubly confusing. The requests are coming from Salesforce so I don’t have the IP but you should be able to see it on your end.

What’s odd is that in you API logs there isn’t a body that’s showing an internal server error. That’s why we need the IP address to find the issue. Do you know what IP address these requests are coming from? We don’t have a way to find it on our end nor can we confirm we’re looking at the right ones. :slightly_smiling_face:

The Square API response does include the HTTP/1.1 500 Internal Server Error message I sent you, I got that directly from the Square response.

Salesforce orgs do not have single, static IP addresses - if it helps you can see the US-based ranges here: Help And Training Community

You can see the specific requests in your API logs, and see that they are returning 406 errors. What are you saying you don’t have “a way to find”?

Hi, has the team responded with the reason why the request we are sending would ever result in this 406 error? The customer has not been able to create their invoices for a week now.

The team is still looking into this. Was the customer able to create invoices previously? I’m not seeing any in the logs. :slightly_smiling_face:

Hi Bryan,

No, this is a brand new integration with Salesforce that I am working to set up. I’ve only been working in the sandbox.

Looks like the issue is with accept. This is what you have it set to:

content-length: 419
square-version: 2021-07-21
content-type: application/json;charset=UTF-8
cache-control: no-cache
pragma: no-cache
accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
user-agent: SFDC-Callout/55.0

If you change it to */* does it work? :slightly_smiling_face:

That resolved the 406 (now I have a 400 - but that’s an issue I can figure out). I haven’t had accept in the header for any other API calls. Why does the invoices API fail without it? And will it cause any issues if I add it into the other API calls (customers, orders, etc)?

Great, glad to hear that did it. In your earlier requests it was set to:

accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

Was this something that the application you’re using set it to without you overriding it? :slightly_smiling_face:

Um, I think my post got hijacked…? @Bryan-Square I don’t know who @crhhe3 is (?), but to answer your previous question, yes the customer was able to create invoices previously. Like I mentioned in the original post, this has been running for a year already.

“Accept” is not a header we are sending, the Square API docs only say to include the below, which worked fine until now:

-H ‘Square-Version: 2022-07-20’
-H ‘Authorization: Bearer ACCESS_TOKEN’
-H ‘Content-Type: application/json’ \

When you say " If you change it to */* does it work?", what do you mean by “it”? Please specify the exact change you are suggesting.

Sorry @numberforty1. I thought I was responding to an email, rather than this post. I am also integrating with Salesforce and hit the same 406 error. Didn’t mean to hijack.

@numberforty1 It appears that the Salesforce integration that you’re using is setting the Accept for you. When we get the request it looks like accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 and that is what’s causing the issue. We’ve been able to replicate this on our end as well. :slightly_smiling_face: