question

m-pinto-2009 avatar image
0 Likes"
m-pinto-2009 asked

GetSingleItem Stopped working this week

Hi,

I have been making API Calls successfully to retrieve my active listings details but since Tuesday 5/10/21 they have stopped working. Below is a section of my php script that has been working for years.


$endpoint = 'https://open.api.ebay.com/shopping';


$apicall = "$endpoint?callname=GetSingleItem&version=863&siteid=3"

. "&appid=MyAppID"

. "&ItemID=$SafeItemID"

. "&responseencoding=$responseEncoding"

. "&descriptionSearch=true"

. "&DetailLevel=ReturnAll"

. "&IncludeSelector=Details, Description, TextDescription,ItemSpecifics,Variations,FeedbackHistory";


I retrieve the info I require by using:

$description= $resp['Item_Description'];

But I get the php error: Notice: Undefined index: Item_Description


So I am not sure if the GetSingleItem APICALL requires new / additional changes as I can't find anything relevant in the Developers API Documentation.


Any help would be greatly appreciated please to point me in the right direction to fix this.


Thank you.

getsingleitemgetsingleitem descriptionphp-getsingleitem-id
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dopi.dizajn avatar image
0 Likes"
dopi.dizajn answered

Hi, you need to use X-EBAY-API-IAF-TOKEN in header

Example:

webRequest.Method = "GET";

webRequest.Headers.Add("X-EBAY-API-IAF-TOKEN", access_token);

webRequest.ContentType = "application/json";

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

m-pinto-2009 avatar image
0 Likes"
m-pinto-2009 answered

Thank you for you reply. Is this something that has changed this week as never had to send headers before? Thanks.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dopi.dizajn avatar image
0 Likes"
dopi.dizajn answered

Sending request with header has started 1 July this year. But, before few days eBay has deprecated old API so now it's only way to send request using header.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

m-pinto-2009 avatar image
0 Likes"
m-pinto-2009 answered

So I have added my access token but I think the problem lies somewhere else as the errors are showing:

ACK: Failure
Version: 867
Build: 19110890

eBay results_error: Error Code:2
shortMsg: Unsupported API call.
longMsg: The API call "GetSingleItem" is invalid or not supported in this release.
SeverityCode: Error
ErrorClassification: RequestError


I am creating APICall as below:

$session = new eBaySession($devID, $appID, $certID, $serverUrl, $API_Version, $siteID, $verb);

Variables set prior to session:

$serverUrl = 'https://api.ebay.com/ws/api.dll';

$shoppingURL = 'https://open.api.ebay.com/shopping';

If I change $serverUrl to $shoppingURL I get "Error sending request " so $serverUrl must be correct

Look for my responses:

$responses = $responseDoc->getElementsByTagName("GetSingleItemResponse");


So really at a loss as to what is going on with this as it has been working for years literally!!

If any more info is required please let me know.

Thanks again for any help.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

michab2003 avatar image
0 Likes"
michab2003 answered

sometimes you can spend hours checking your own code or just take a look at something that is working. then start comparing and usually, u find the messing part more quickly. so here´s my advise:

  • install postman: https://www.postman.com
  • on top left (at your collection) there is a "Import" button
  • import this json
  • in the headers-tab, put in a valid oauth token:


then the call should work. and you should be able to compare this to whatever you are doing and properly you will see, what´s wrong.

btw, postman has a nice feature, you can transform any request to php code, this sometimes is a help, too.






1633865015020.png (54.8 KiB)
1633865023100.png (81.6 KiB)
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

m-pinto-2009 avatar image
0 Likes"
m-pinto-2009 answered

Hi @michab2003, thank you for info and clear instructions. So have loaded JSON script into Postman and add my token which from you example starts the same with a "v" and I got this from the eBay API test tool which when I execute my call request works but in postman it reports the below so no sure why the token works in the API tool but not outside!


<?xml version="1.0" encoding="UTF-8"?><GetSingleItemResponse xmlns="urn:ebay:apis:eBLBaseComponents"><Timestamp>2021-10-10T11:46:16.498Z</Timestamp> <Ack>Failure</Ack> <Errors> <ShortMessage>Invalid token.</ShortMessage> <LongMessage>Invalid token. Please specify a valid token as HTTP header.</LongMessage> <ErrorCode>1.32</ErrorCode> <SeverityCode>Error</SeverityCode> <ErrorClassification>RequestError</ErrorClassification> </Errors> <Build>E1199_CORE_APILW_19146596_R1</Build> <Version>1199</Version></GetSingleItemResponse>
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

michab2003 avatar image
0 Likes"
michab2003 answered

sometimes people use the wrong token. there are two types of tokens:

https://developer.ebay.com/api-docs/static/oauth-token-types.html

- Application access token

- User access token

maybe u are using the "application" token here instead of the "user" token.

if u get the token inside the ebay API test tool and copy it into postman, that should work.

it´s important, that the "scopes" of your token support the request, you are going to make.

more important: the token has a short lifetime, I guess 2 hours or something.

so to be sure, the token is still valid, always test with a fresh one.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

m-pinto-2009 avatar image
0 Likes"
m-pinto-2009 answered

OK so that makes sense as I was getting info back and now it has stopped so guessing the token being used in API tool is different and has changed. Which one should I be using that doesn't keep changing or do i have to mint a new one every time i want to make a shopping APICall?

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

michab2003 avatar image
0 Likes"
michab2003 answered

sorry, my fault. as the docu clearly says: https://developer.ebay.com/devzone/shopping/docs/concepts/shoppingapiguide.html

"developers using Shopping API calls must authenticate with an OAuth application access token"

so the "application access token" has to be used here and not the "user access token".

the grant flow is explained here:

https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html

on that site you see, that the "application token" has a lifetime of 7200 seconds, so 2 hours.

so when it comes to the "application token", there´s NOT the usual flow where an "ebayuser" is involved, so you don´t see any refresh token. just get yourself a token and save it for further calls.

if the token is no longer valid, get a new one and replace the last/old one.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

m-pinto-2009 avatar image
0 Likes"
m-pinto-2009 answered

So this is where it gets confusing as up until it stopped working last week in my headers is was sending X-EBAY-API-DEV-NAME , X-EBAY-API-APP-NAME and X-EBAY-API-APP-NAME and all worked OK and now will only work if I add now only works if I add X-EBAY-API-IAF-TOKEN but then only works for the 2 hours. So surely I don't have to keep renewing my token to run a call everytime from my script?

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.