3

I'm planning to integrate a website with eBay using PHP, but first I'm using Postman to test everything.

Authorization took me an entire day, but I think I've got it working now. (I had to update to the latest version of Postman, then I got it to create a token for me.)

I say I think because I haven't managed to get a single request to work. I deliberately chose bulkGetInventoryItem (documentation) as it seemed like one of the easier authorized requests to get working. I just know that when the authentication settings are wrong, I get a different error message to when they are right.

For troubleshooting reasons, I made a token with all the scopes:

(added as space-separated list of links)

I have changed one of the eBay listings to have an SKU of "123456" just for this test, however the error I get is exactly the same as if I change "sku": "123456" to "sku": "anObviouslyFakeSKU", but anything else I change creates a new error, so I'm suspecting the issue to be SKU related, but maybe it isn't. (I've found the eBay API to be very poor at sending relevant error messages.)

I'm quite new to Postman, so it's likely a rookie mistake.

Earlier errors have shown to be minor punctuation issues or wrong radio buttons ticked, so hopefully whatever the error is this time, it should appear in this screenshot.

What did I do wrong this time? (Let me know if there are any other screenshots I can send that might help.)

screenshot

To help, both with the post's SEO, and ease of copy/pasting, I am transcribing the important text in the screenshot above:

url

POST https://api.ebay.com/sell/inventory/v1/bulk_get_inventory_item

body, raw

{
  "requests": [
    {
      "sku": "123456"
    }
  ]
}

output

{
    "errors": [
        {
            "errorId": 2003,
            "domain": "ACCESS",
            "category": "APPLICATION",
            "message": "Internal error",
            "longMessage": "There was a problem with an eBay internal system or process. Contact eBay developer support for assistance",
            "parameters": [
                {
                    "name": "reason",
                    "value": "Failed to transform underlying error response, see logs."
                }
            ]
        }
    ]
}

Update: One more screenshotenter image description here

Update 2: Another screenshotenter image description here

2 Answers2

3

A few things you need to check for in Postman.

  1. When you authenticate and receive a token are you posting that token with your api calls like this one POST https://api.ebay.com/sell/inventory/v1/bulk_get_inventory_item?

  2. Have you set the Authorization HTTP header for authentication authorization?

  3. Have you set the Content-Type header for the call to application/json?

More info here: https://developer.ebay.com/api-docs/sell/inventory/resources/inventory_item/methods/bulkGetInventoryItem

Update

Authorization with environment variable in Postman:

Authorization with environment variable

Postman environment variables documentation: https://learning.postman.com/docs/postman/variables-and-environments/variables/

Community
  • 1
  • 1
IceCode
  • 1,466
  • 13
  • 22
  • Yes, yes, and yes. The authorisation generates 10 temporary headers and `application/json` makes the 11th. Perhaps expand on point 2, because maybe I just thought I did that and didn't. Though 1 and 3, I definitely 100% did for certain. I get a different error message if I undo those steps. – Jonathon Philip Chambers Feb 24 '20 at 08:08
  • My Authorization HTTP header starts with "`Bearer v^1.1#i^1#r^0#I^3#f^0#p^3#t^H4`..." (Obviously I'm not going to copy the whole thing) – Jonathon Philip Chambers Feb 24 '20 at 08:10
  • How we do it in Postman is that we first authenticate through the api and receive the token. The token we receive back is saved in a `environment` variable in Postman. We then use that environment varible with the token value for the other post or get api calls. I have added an image for how it looks on our end in postman. – IceCode Feb 24 '20 at 08:44
  • Sorry for the late reply. Set your authentication type to "Bearer Token". And put the following in the header `grant_type=authorization_code` Could also be that you have to put it in the body of the request. Hope this helps. – IceCode Feb 25 '20 at 07:13
  • { "errors": [ { "errorId": 1002, "domain": "OAuth", "category": "REQUEST", "message": "Missing access token", "longMessage": "Access token is missing in the Authorization HTTP request header." } ] } I think I had authorization the first time. Now I no longer have authorization – Jonathon Philip Chambers Feb 25 '20 at 07:22
  • Try to put your token in where you changed the `Authorization` to Bearer in the field to the right with your `v^1.1#i^1#r^0#I^3#f^0#p^3#t^H4...` – IceCode Feb 25 '20 at 07:29
  • It's already there. It was put there automatically. I don't think this is an authorisation error. I'm very familiar with the authorisation error response whenever the token is even slightly wrong. This recognises my token as correct, granted me access, but is having trouble understanding my request for some unknown reason. – Jonathon Philip Chambers Feb 25 '20 at 07:34
  • 3rd screenshot added – Jonathon Philip Chambers Feb 25 '20 at 07:37
  • Just to be clear here. When using oAuth you first authenticate yourself by calling ebay´s authentication url which is the following: `https://api.ebay.com/oauth/api_scope/sell.inventory`. The authentication call return´s a token. That token you need to pass to the `https://api.ebay.com/sell/inventory/v1/bulk_get_inventory_item` request. Are you calling the authentication url first? – IceCode Feb 25 '20 at 07:51
  • Sort of. The technique I use is described here https://github.com/postmanlabs/postman-app-support/issues/3537#issuecomment-332115078 and it seems to get me past all authentication errors. I am certain this error is not related to authentication – Jonathon Philip Chambers Feb 25 '20 at 07:54
  • Also, I know the authentication works because it times out when the token expires. And I have to keep getting new tokens as I try to tackle this problem. – Jonathon Philip Chambers Feb 25 '20 at 07:57
1

I figured out the issue. My biggest mistake was choosing bulkGetInventoryItem as the "simplest" call. I should have chosen getInventoryItem, as the error reporting on that function is far more user friendly.

So the error I got, for exactly the same request was "We didn't find the entity you are requesting. Please verify the request"

A quick google of the error found me this page https://forums.developer.ebay.com/questions/17883/cannot-get-my-listed-product-by-get-inventory-api.html which led me to the correct answer!

The inventory item I was trying to access was unreachable because it was not created through the developer API.

I hope this answer helps others, as it wasted a full day of my life trying getInventoryItem before tackling bulkGetInventoryItem.

  • So this is to say, you can only access data made through the developer API? Why did they design it this way? Seems a bit too restrictive. Is the entire API built this way or just specific ones? – Urasquirrel Mar 10 '21 at 15:10
  • This seems like a huge limitation. So to clarify i can not get any information on existing listings, only listing created by the API? Is this still the case? I would like to know before i jump into the deep end of testing and integrating this API. Thanks. – Lucas Rahn Nov 17 '21 at 16:30