question

John Crennan avatar image
0 Likes"
John Crennan asked ·

findCompletedItems Response show undefined for some fields

I am trying to create a completed items response and in some fields I am getting the response undefined. I know I am missing something very basic but cannot work it out. What am I missing?

 

eBay Search Results

undefined undefined Apple iPhone 4S - 16GB - Black Smartphone Unlocked undefined undefined Apple iPhone 4S - 16GB - Black - * Unlocked *

 

I am also getting and error in the XML window when testing in the Quick Start Sample Application

XML Parsing Error: not well-formed
Location: http://developer.ebay.com/quickstartguide/sample/js/SampleJS.aspx?sUrl=h...{ADD YOUR APP ID}%26RESPONSE-DATA-FORMAT%3dXML%26callback%3d_cb_findCompletedItems%26REST-PAYLOAD%26keywords%3diPhone%26categoryId%3d9355%26itemFilter(0).name%3dCondition%26itemFilter(0).value%3d3000%26itemFilter(1).name%3dFreeShippingOnly%26itemFilter(1).value%3dtrue%26itemFilter(2).name%3dSoldItemsOnly%26itemFilter(2).value%3dtrue%26paginationInput.entriesPerPage%3d2%26GLOBAL-ID%3dEBAY-AU
Line Number 1, Column 23:_cb_findCompletedItems({"findCompletedItemsResponse":[{"ack":["Success"],"version":["1.12.0"],"timestamp":["2013-08-03T14:32:21.229Z"],"searchResult":[{"@count":"2","item":[{"itemId":["330974335812"],"title":["Apple  iPhone 4S - 16GB - Black Smartphone Unlocked"],"globalId":["EBAY-AU"],"subtitle":["Brand new life proof iphone case inc worth $80"],"primaryCategory":[{"categoryId":["9355"],"categoryName":["Mobile Phones"]}],"galleryURL":["http:\/\/thumbs1.ebaystatic.com\/m\/m6eaUOkK4ftmE1aW55aY5Yg\/140.jpg"],"viewItemURL":["http:\/\/www.ebay.com.au\/itm\/Apple-iPhone-4S-16GB-Black-Smartphone-Unlocked-\/330974335812?pt=AU_Mobile_Phones"],"productId":[{"@type":"ReferenceID","__value__":"110671348"}],"paymentMethod":["PayPal","COD"],"autoPay":["false"],"postalCode":["6035"],"location":["Perth,WA,Australia"],"country":["AU"],"shippingInfo":[{"shippingServiceCost":[{"@currencyId":"AUD","__value__":"0.0"}],"shippingType":["Free"],"shipToLocations":["AU"]}],"sellingStatus":[{"currentPrice":[{"@currencyId":"AUD","__value__":"420.0"}],"convertedCurrentPrice":[{"@currencyId":"AUD","__value__":"420.0"}],"sellingState":["EndedWithSales"]}],"listingInfo":[{"bestOfferEnabled":["false"],"buyItNowAvailable":["false"],"startTime":["2013-07-31T11:48:46.000Z"],"endTime":["2013-08-03T13:27:23.000Z"],"listingType":["FixedPrice"],"gift":["false"]}],"condition":[{"conditionId":["3000"],"conditionDisplayName":["Used"]}],"isMultiVariationListing":["false"],"topRatedListing":["false"]},{"itemId":["200949398896"],"title":["Apple  iPhone 4S - 16GB - Black - * Unlocked *"],"globalId":["EBAY-AU"],"primaryCategory":[{"categoryId":["9355"],"categoryName":["Mobile Phones"]}],"galleryURL":["http:\/\/thumbs1.ebaystatic.com\/m\/m6eaUOkK4ftmE1aW55aY5Yg\/140.jpg"],"viewItemURL":["http:\/\/www.ebay.com.au\/itm\/Apple-iPhone-4S-16GB-Black-Unlocked-\/200949398896?pt=AU_Mobile_Phones"],"productId":[{"@type":"ReferenceID","__value__":"110671348"}],"paymentMethod":["PayPal"],"autoPay":["false"],"postalCode":["3000"],"location":["Melbourne,VIC,Australia"],"country":["AU"],"shippingInfo":[{"shippingServiceCost":[{"@currencyId":"AUD","__value__":"0.0"}],"shippingType":["Free"],"shipToLocations":["AU"]}],"sellingStatus":[{"currentPrice":[{"@currencyId":"AUD","__value__":"390.0"}],"convertedCurrentPrice":[{"@currencyId":"AUD","__value__":"390.0"}],"sellingState":["EndedWithSales"]}],"listingInfo":[{"bestOfferEnabled":["false"],"buyItNowAvailable":["false"],"startTime":["2013-08-03T10:22:35.000Z"],"endTime":["2013-08-03T13:17:40.000Z"],"listingType":["FixedPrice"],"gift":["false"]}],"condition":[{"conditionId":["3000"],"conditionDisplayName":["Used"]}],"isMultiVariationListing":["false"],"topRatedListing":["false"]}]}],"paginationOutput":[{"pageNumber":["1"],"entriesPerPage":["2"],"totalPages":["277"],"totalEntries":["553"]}]}]})
 

findcompleteditems
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.

$$anonymous$$ avatar image
0 Likes"
$$anonymous$$ answered ·

You're trying to get nodes that don't exist.CurrentPrice isn't at the root level of item. 

 

Look at the XML output in your browser to see the hierarchy. You can also load a JSON viewer add-on into Firefox to do this with the JSON output. Or just read the docs, there's a sample output there.

· 2 · Share
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.

I get the same Undefined value when I use the values from the API table: var shipping = item.shippingInfo.shippingServiceCost; var price = item.sellingStatus.currentPrice; var bin = item.listingInfo.buyItNowPrice; Am I missing something?
0 Likes 0 · ·
Fields marked "Conditionally" in the docs are not always returned. You have to test for existence before using them. BuyItNow price for instance, isn't returned for auctions that do not have a BuyItNow option.
0 Likes 0 · ·
John Crennan avatar image
0 Likes"
John Crennan answered ·

Sorry here was my code

 

<html>
<head>
<title>eBay Search Results</title>
<style type="text/css">body { font-family: arial,sans-serif;} </style>
</head>
<body>
<h1>eBay Search Results</h1>
<div id="results"></div>

<script>
function _cb_findCompletedItems(root)
{
  var items = root.findCompletedItemsResponse[0].searchResult[0].item || [];
  var html = [];
  html.push('<table width="100%" border="0" cellspacing="0" cellpadding="3"><tbody>');

  for (var i = 0; i < items.length; ++i)  
  {
    var item     = items[i];
    var title    = item.title;
    var Price      = item.currentPrice;
    var shipping = item.shippingServiceCost;

      html.push('<tr><td>' + Price + '</td>' +
        '<td>' + shipping + ' ' + title + '</td></tr>');

  }
  html.push('</tbody></table>');
  document.getElementById("results").innerHTML = html.join("");
}
</script>

<!--
Use the value of your appid for the appid parameter below.
-->
<script src=http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findCompletedItems&SERVICE-VERSION=1.7.0&SECURITY-APPNAME={ADD YOUR APP ID}&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findCompletedItems&REST-PAYLOAD&keywords=iPhone&categoryId=9355&itemFilter(0).name=Condition&itemFilter(0).value=3000&itemFilter(1).name=FreeShippingOnly&itemFilter(1).value=true&itemFilter(2).name=SoldItemsOnly&itemFilter(2).value=true&paginationInput.entriesPerPage=2&GLOBAL-ID=EBAY-AU>
</script>
</body>
</html>

· Share
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.