question

inoxia_ltd avatar image
0 Likes"
inoxia_ltd asked

eBay Trading API requires parameters for GetOrders method, but to process, some need to be valueless. Null, not accepted

I'm using the eBay Trading API, Visual Studio, C#, with the eBay NuGet Package installed, which creates eBay objects and methods for me. The definition of the GetOrders(...) method is:~

 
               
public OrderTypeCollection GetOrders(StringCollection OrderIDList, DateTime CreateTimeFrom, DateTime CreateTimeTo, TradingRoleCodeType OrderRole, OrderStatusCodeType OrderStatus, ListingTypeCodeType ListingType, PaginationType Pagination, DateTime ModTimeFrom, DateTime ModTimeTo, int NumberOfDays, bool IncludeFinalValueFee, SortOrderCodeType SortingOrder);

Almost all of these parameters are required, null is not accepted. Some will accept blank variables. So I have this code to call the method:


var roletype = TradingRoleCodeType.Seller;
var orderstatuscode = OrderStatusCodeType.All;
var pagination = new PaginationType(); pagination.EntriesPerPage = itemsPerPage; pagination.PageNumber = pageNumber;
int noOfDays = new int(); DateTime blankDate = new DateTime();  // Not blank, but 01/01/0001 12:00:00 AM
orders = apicall.GetOrders(null, fromDate, toDate, roletype, orderstatuscode, new ListingTypeCodeType(), pagination, blankDate, blankDate, noOfDays, false, SortOrderCodeType.Ascending);

This code will run, but returns the error "Do not provide CreateTimeFrom/To as well as ModTimeFrom/To, only provide one or the other" If I write my own calls to the API, I can just leave out the unrequired parameters, but by using the methods built by the eBay Nuget package, I'm forced to submit parameters. To me, it appears impossible to use this method, because it requires two sets of dates to submit, but if submitted with two sets of dates, it is rejected by the server.

I'm fairly new to C#, so there's possibly something simple I'm missing. There are 3 overloads for the method, but none of the accept the required set of parameters.

trading api.net sdk
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.

inoxia_ltd avatar image
0 Likes"
inoxia_ltd answered

I needed to pick one of the simpler GetOrders overflows, with less parameters. Then feed in optional parameters into the parent object. For example:


var roletype = TradingRoleCodeType.Seller;
var orderstatuscode = OrderStatusCodeType.All;
var pagination = new PaginationType();
pagination.EntriesPerPage = itemsPerPage;
pagination.PageNumber = pageNumber;
apicall.Pagination = pagination;
orders.AddRange(apicall.GetOrders(fromDate, toDate, roletype , orderstatuscode));


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.

sagar_developersupport avatar image
0 Likes"
sagar_developersupport answered

Hi @inoxialtd,

CreateTimeFrom/To as well as ModTimeFrom/To both are different filters in getOrders, You have to use only while making the request either it is CreateTimeFrom/To or ModTimeFrom/To

Ref CreateTimeFrom:-https://developer.ebay.com/devzone/xml/docs/reference/ebay/getorders.html#Request.CreateTimeFrom
Ref CreateTimeTo:-https://developer.ebay.com/devzone/xml/docs/reference/ebay/getorders.html#Request.CreateTimeTo
Ref ModTimeFrom:- https://developer.ebay.com/devzone/xml/docs/reference/ebay/getorders.html#Request.ModTimeFrom
Ref ModTimeTo:- https://developer.ebay.com/devzone/xml/docs/reference/ebay/getorders.html#Request.ModTimeTo

Best regards ,
eBay Developer Support

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.

inoxia_ltd avatar image
0 Likes"
inoxia_ltd answered

Thanks you for your support.
I understand that I should only supply either CreateTime or ModTime parameters.

The problem comes when using the GetOrders method in the .NET SDK.

  1. public OrderTypeCollection GetOrders(StringCollection OrderIDList, DateTime CreateTimeFrom, DateTime CreateTimeTo, TradingRoleCodeType OrderRole, OrderStatusCodeType OrderStatus, ListingTypeCodeType ListingType, PaginationType Pagination, DateTime ModTimeFrom, DateTime ModTimeTo, int NumberOfDays, bool IncludeFinalValueFee, SortOrderCodeType SortingOrder);

Which I use with my code below;


orders = apicall.GetOrders(null, fromDate, toDate, roletype, orderstatuscode, new ListingTypeCodeType(), pagination, blankDate, blankDate, noOfDays, false, SortOrderCodeType.Ascending);

I can't pass blank values to the 'CreateTimeFrom', 'CreateTimeTo', 'ModTimeFrom' or 'ModTimeTo'. If I try to set any of these to null the program throws an error at compile time.


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.