After spending many hours trying to understand Amazon’s API for accessing reports, I’ve finally come up with a solution. Below is one way to download an unshipped orders report.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
String accessKeyId = "YourSecretKey"; String secretAccessKey = "YourSecretAccessKey"; MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig(); config.ServiceURL = "https://mws.amazonservices.com"; const string applicationName = "ApplicationName"; const string applicationVersion = "0.1a"; MarketplaceWebServiceClient service = new MarketplaceWebServiceClient( accessKeyId, secretAccessKey, applicationName, applicationVersion, config); const string merchantId = "YourMerchantID"; const string marketplaceId = "YourMarketplaceID"; RequestReportRequest reportRequestRequest = new RequestReportRequest(); reportRequestRequest.Merchant = merchantId; reportRequestRequest.Marketplace = marketplaceId; reportRequestRequest.ReportType = "_GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_"; RequestReportResponse requestResponse = service.RequestReport(reportRequestRequest); Thread.Sleep(15000); //wait 15 seconds for order to process GetReportListRequest listRequest = new GetReportListRequest(); listRequest.Merchant = merchantId; listRequest.Marketplace = marketplaceId; GetReportListResponse listResponse = service.GetReportList(listRequest); GetReportListResult getReportListResult = listResponse.GetReportListResult; List<ReportInfo> reportInfoList = getReportListResult.ReportInfo; ReportInfo myReportInfo = reportInfoList[0]; GetReportRequest reportRequest = new GetReportRequest(); reportRequest.Merchant = merchantId; reportRequest.Marketplace = marketplaceId; String source = path + "\\XMLReport.xml"; reportRequest.ReportId = myReportInfo.ReportId; reportRequest.Report = File.Open(source, FileMode.Create, FileAccess.ReadWrite); service.GetReport(reportRequest); GetReportRequestListRequest reportRequestListRequest = new GetReportRequestListRequest(); reportRequestListRequest.Marketplace = marketplaceId; reportRequestListRequest.Merchant = merchantId; List<ReportRequestInfo> myListzz = new List<ReportRequestInfo>(); GetReportRequestListResponse reportRequestListResponse = new GetReportRequestListResponse(); reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest); GetReportRequestListResult reportRequestListResult = new GetReportRequestListResult(); reportRequestListResult = reportRequestListResponse.GetReportRequestListResult; myListzz = reportRequestListResult.ReportRequestInfo; while (myListzz[0].ReportProcessingStatus.ToString() != "_DONE_") { lblStatus.Text = "Waiting for Report"; Thread.Sleep(61000); reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest); reportRequestListResult = reportRequestListResponse.GetReportRequestListResult; myListzz = reportRequestListResult.ReportRequestInfo; } |
Hopefully this example will help others trying to do something similar. Please let me know if you have any questions and I’ll do my best to help.