简体   繁体   中英

eBay Trading API requires parameters for GetOrders method required, 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.

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 orderstatuscode = OrderStatusCodeType.All;
                var pagination = new PaginationType();
                pagination.EntriesPerPage = itemsPerPage;
                pagination.PageNumber = pageNumber;
                apicall.Pagination = pagination;
                orders.AddRange(apicall.GetOrders(fromDate, toDate, roletype , orderstatuscode));

-- Edit -- After doing more work with the code, I've found an even more flexible way of getting this to support a custom selection of parameters.

                while (hasOrders)
                {
                    Console.WriteLine("Getting page {0}.... ", pagination.PageNumber);

                    apicall.Pagination = pagination;
                    apicall.ModTimeFrom = fromDate;
                    apicall.ModTimeTo = toDate;
                    apicall.OrderRole = TradingRoleCodeType.Seller;
                    apicall.OrderStatus = OrderStatusCodeType.All; ;
                    apicall.Execute();
                    orders.AddRange(apicall.ApiResponse.OrderArray);
                   //orders.AddRange(apicall.GetOrders(fromDate,toDate, roletype, orderstatuscode));   // No overflow will support modified date.
                    hasOrders = apicall.HasMoreOrders;
                    pagination.PageNumber++;
                }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM