What would be the best way to retrieve orders from Amazon MWS?
My current code is as follows…
MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig();
config.ServiceURL = productsURL;
MarketplaceWebServiceOrders.MarketplaceWebServiceOrdersClient service = new MarketplaceWebServiceOrdersClient(appname, version, accesskeyID, secretkey, config);
ListOrdersRequest request = new ListOrdersRequest();
request.MarketplaceId = new MarketplaceIdList();
request.MarketplaceId.Id = new List<string>(new string[] { marketids[0] });
request.SellerId = merchantID;
request.OrderStatus = new OrderStatusList() { Status = new List<OrderStatusEnum>() { OrderStatusEnum.Unshipped, OrderStatusEnum.PartiallyShipped } };
request.CreatedAfter = Convert.ToDateTime(dc.Settings.SingleOrDefault().lastOrdersRetrieved);
ListOrdersResponse response = service.ListOrders(request);
I am having issues passing the ISO Date across, also if you see any other issues with the code please feel free to let me know.
If your looking for something created after the immediate second you make the request, it wont find anything at all as with Amazon you can only grab up to the last 2 minutes of data for orders.
I had an issue with trying to set time from Now – 5 minutes. After speaking to Amazon support they provided the following nugget: “
In your case you will want to remove the
CreatedAfterrequest and let Amazon choose for you.If you are then looking for the created after, you can grab the response time Amazon gave and pass that in to your created after param.
The method I have right now to list orders is as follows, mind you this will just list the orders to console, but the data gets returned all the same: