401 Authorization Error on API access

I am writing an interface from our internal order entry to the shiphero API and I can’t get past the transport layer error 401. I do have a token and I think I have created the appropriate headers but I suspect that the authorization header is not quite correct. Is there a sample anywhere of what the proper headers and format are? Failing that, how would I go about debugging this? Our logistics company is the shiphero user and just changed this month so they can’t give us a lot of technical help.

Hey @johni,

Thanks for reaching out!

Would you mind sharing with me the full request/response along with the headers that you are using to make the attempted call?

I’ve started a private message between us, to continue this further.


Thanks Ryan:

I’m a little bit out of my element here but I think what I should be doing is:

using https as the protocol, I have to add headers as follows:

[header] => Array
[0] => “Content-type”: “application/json”

                [1] => "Content-Length": 171

                [2] => "User-Agent":"Mozilla/5.0" + "Linux x86_64; Gecko/0100101

[3] => “Authorization”: "Bearer
kEfqCmHpIE5LnEQo8JgmzKS”,“scope”:"openid profile view:products change:products view:orders
change:orders view:purchase_orders change:purchase_orders view:shipments change:shipments
view:returns change:returns view:warehouse_products change:warehouse_products view:picking_stats
view:packing_stats offline_access

I’m just sending some simplistic content to check that I have a connection (I don’t have yet) so the
content is:

[content] =>

The response that I get from shiphero is:

====Dumping response header====
array(6) {
string(25) “HTTP/1.1 401 UNAUTHORIZED”
string(35) “Date: Wed, 27 Dec 2023 17:53:29 GMT”
string(38) “Content-Type: text/html; charset=utf-8”
string(18) “Content-Length: 47”
string(17) “Connection: close”
string(13) “Server: nginx”

====end of response header===

I am writing in PHP since this is triggered from the server when an order is placed and everything
else there is in PHP. I cribbed the header format from the Python example in the docs.

Other information that might be useful:

O/S - Rocky Linux 9.2 (ie RHEL 9.1)
PHP version: 8.0.30
Apache 2.4.53 (but at the moment I am running from the command line)

The token shown in the headers above is the company’s live token but at the moment HyperNile (the
actual shiphero user) knows not to ship anything for us that turns up on their new system. Before
we go live I will refresh it.

Please let me know if you need anything else.



Hi Rayanp: Any ideas yet or should I provide additional information? Our logistics company is changing to ship-hero next week at the start of the new year.

Hey @johni,

Contining this conversation via PM.