01-31-2024 01:18 PM
Hi
I'm trying to make a request to ebay's api through python request module. I keep getting error code 400, however I'm able to get back a response on postman, unless I remove the host header.
The headers I'm using are:
headers = {
"X-EBAY-C-MARKETPLACE-ID": "EBAY_GB",
"Authorization": "Bearer OAuth Application Token"
}
I think the reason why I'm getting error code 400 is because I'm missing the host header. Does anyone know host header I need to use?
Thank you.
01-31-2024 02:04 PM
Which API are you addressing? I can't locate that header combination.
01-31-2024 02:15 PM
I'm using
https://api.ebay.com/buy/browse/v1/item_summary/search?q=drone&limit=3
01-31-2024 03:52 PM
Start by acquiring an OAuth token to access public data:
https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html
That call will return an access_token.
The Browse API:
https://developer.ebay.com/api-docs/buy/browse/resources/item_summary/methods/search
The API Explorer will assist in generating headers for the call to the browse API by showing how they are constructed.
https://developer.ebay.com/my/api_test_tool?index=0&env=production
Such as shown below:
X-EBAY-C-MARKETPLACE-ID:EBAY_GB
Authorization:Bearer v^1.1#i^1#p^3#I^3#r^0#f^0#t^H4sIAAAAA...SggHgAA
How the header is quoted or encoded/decoded is up to your server language.
Your header appears to be correctly formatted for Python if it looks like this:
headers = {
"X-EBAY-C-MARKETPLACE-ID": "EBAY_GB",
"Authorization": "Bearer v^1.1#i^1#p^3#I^3#r^0#f^0#t^H4sIAAAAA...SggHgAA"
}
Others have reported issues with Postman when making calls, but I don't have any details. Sorry.