Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetOrders API call returning no orders on Ebay sandbox Account

Tags:

java

ebay-api

I have placed test orders in the sandbox Ebay account, but I am not able to get the order details from GetOrder call. I get the success message, but no order are fetched. Can someone help me?

This is my code:

private static ApiContext getApiContext() throws IOException {

    String input;
    ApiContext apiContext = new ApiContext();
    // set devId, appId, certId in ApiAccount
    ApiAccount account = new ApiAccount();
    account.setDeveloper("xxxx");
    account.setApplication("xxxxx");
    account.setCertificate("xxxxxx");

    ApiCredential cred = apiContext.getApiCredential();
    cred.setApiAccount(account);

    cred.seteBayToken("xxxxxxxxxxx");

    apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi");

    apiContext.setWSDLVersion("897");

    return apiContext;

public static void main(String[] args) {

    try {

        System.out.println("===== [1] Account Information ====");
        ApiContext apiContext = getApiContext();
        GetOrdersCall orders = new GetOrdersCall(apiContext);
        SimpleDateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy");

        String Startdate = "Wed Apr 20 12:53:10 IST 2015";  
        String Enddate = "Fri Apr 27 12:53:10 IST 2015";

        Date date1 = formatter.parse(Startdate);
        System.out.println(date1);

        Date date2 = formatter.parse(Enddate);
        System.out.println(date2);
        Calendar calFrom=Calendar.getInstance();
        Calendar calTo=Calendar.getInstance();
        calFrom.setTime(date1);
        orders.setCreateTimeFrom(calFrom);
        calTo.setTime(date2);
        orders.setCreateTimeTo(calTo);
        orders.setWarningLevel(WarningLevelCodeType.HIGH);
        orders.setOrderRole(TradingRoleCodeType.SELLER);
        orders.setOrderStatus(OrderStatusCodeType.ACTIVE);

        OrderType[] os = orders.getOrders();
        System.out.println("Length"+os.length);


        System.out.println(orders.getRequestXml()+orders.getResponseXml());
        for(OrderType o:os){
            System.out.println(o.getOrderID());
        }
    }

    catch(Exception e) {
        System.out.println("Fail to get order the item.");
        e.printStackTrace();
    }

This is the request XML:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">

 <S:Header>
  <ebl:RequesterCredentials xmlns:ebl="urn:ebay:apis:eBLBaseComponents" 
                            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                            SOAP-ENV:mustUnderstand="0">
   <ebl:eBayAuthToken>xxxxx</ebl:eBayAuthToken>
</ebl:RequesterCredentials>
 </S:Header>
 <S:Body>
  <GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">
   <Version>897</Version>

   <WarningLevel>High</WarningLevel>

   <CreateTimeFrom>2015-04-18T12:53:10+05:30</CreateTimeFrom>


   <CreateTimeTo>2015-04-25T12:53:10+05:30</CreateTimeTo>

   <OrderRole>Seller</OrderRole>

   <OrderStatus>Active</OrderStatus>

  </GetOrdersRequest>
 </S:Body>
</S:Envelope>

Response XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header/>
  <soapenv:Body>
    <GetOrdersResponse xmlns="urn:ebay:apis:eBLBaseComponents">
      <Timestamp>2015-04-24T07:03:42.662Z</Timestamp>
      <Ack>Success</Ack>
      <Version>915</Version>
      <Build>E915_CORE_API_17441756_R1</Build>
      <PaginationResult>
        <TotalNumberOfPages>0</TotalNumberOfPages>
        <TotalNumberOfEntries>0</TotalNumberOfEntries>
      </PaginationResult>
      <HasMoreOrders>false</HasMoreOrders>
      <OrderArray/>
      <OrdersPerPage>100</OrdersPerPage>
      <PageNumber>1</PageNumber>
      <ReturnedOrderCountActual>0</ReturnedOrderCountActual>
    </GetOrdersResponse>
  </soapenv:Body>
</soapenv:Envelope>
like image 556
webbee demo Avatar asked Nov 10 '22 15:11

webbee demo


1 Answers

Try to set orderStatus to all. Status of order in ebay api are not so clear.

http://developer.ebay.com/Devzone/XML/docs/Reference/ebay/types/OrderStatusCodeType.html

like image 64
jep Avatar answered Nov 14 '22 21:11

jep