goshippo / shippo-javascript-sdk

MIT License
7 stars 1 forks source link

`client.trackingStatus.create()` causing `SDKError` #44

Closed Cyberuben closed 4 months ago

Cyberuben commented 4 months ago

I'm trying to register a tracking number using client.trackingStatus.create('ups', '<REDACTED>') and I'm getting the following response:

{
  "tracking_number": "<REDACTED>",
  "carrier": "ups",
  "servicelevel": { "name": "Ground", "token": "ups_ground" },
  "transaction": "<REDACTED>",
  "address_from": {
    "city": "Sunnyvale",
    "state": "CA",
    "zip": "94089",
    "country": "US"
  },
  "address_to": {
    "city": "San Francisco",
    "state": "CA",
    "zip": "94114",
    "country": "US"
  },
  "metadata": "<REDACTED>",
  "test": false,
  "tracking_status": {
    "status_date": "2024-05-24T11:13:09.715Z",
    "status_details": "Pre-Transit: Shipment information has been transmitted to the shipping carrier but it has not yet been scanned and picked up.",
    "object_created": "2024-05-24T11:13:09.716Z",
    "object_updated": "2024-05-24T11:13:09.716Z",
    "object_id": "8cf0d899b9dd4137a42bf9ed9b3feae1",
    "status": "PRE_TRANSIT"
  },
  "tracking_history": [
    {
      "status_date": "2024-05-24T11:13:09.715Z",
      "status_details": "Pre-Transit: Shipment information has been transmitted to the shipping carrier but it has not yet been scanned and picked up.",
      "object_created": "2024-05-24T11:13:09.716Z",
      "object_updated": "2024-05-24T11:13:09.716Z",
      "object_id": "8cf0d899b9dd4137a42bf9ed9b3feae1",
      "status": "PRE_TRANSIT"
    }
  ],
  "messages": []
}

Nothing here seems to be out of the ordinary, however, the error I'm getting:

SDKError: Unexpected API response status or content-type: Status 200 Content-Type application/json; charset=utf-8 Body
<Response above>

Response status is 200 and the structure of this response seems to be in order too.

I'm using v2.2.6

Cyberuben commented 4 months ago

Hi, is there anyone from the Shippo team who could follow up? @shippo-lueders

shippo-lueders commented 4 months ago

The issue here is that this is a POST and the client is expecting a 201 rather than a 200 status code, which is what is actually being returned. I'm going to follow up with the owning team and confirm this is a bug, though I don't expect this will be high priority and I might just end up fixing it in the client.

shippo-lueders commented 4 months ago

spoke with the team and it may or may not get fixed... the problem is that existing clients might be relying on this behavior. in any event, I'm going to update the SDK to reflect the actual status code being returned and we can change it back if it does end up getting 'fixed' in the backend. should get an update out tomorrow morning, will close this issue once it's published.

shippo-lueders commented 4 months ago

fixed in https://www.npmjs.com/package/shippo/v/2.2.7