文章来源:http://www.samswiches.com/2011/02/how-to-use-amazon-mws-to-download-unshipped-order-reports/
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 String accessKeyId = "YourSecretKey";
2 String secretAccessKey = "YourSecretAccessKey";
3 MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
4 config.ServiceURL = "https://mws.amazonservices.com";
5 const string applicationName = "ApplicationName";
6 const string applicationVersion = "0.1a";
7
8 MarketplaceWebServiceClient service =
9 new MarketplaceWebServiceClient(
10 accessKeyId,
11 secretAccessKey,
12 applicationName,
13 applicationVersion,
14 config);
15
16 const string merchantId = "YourMerchantID";
17 const string marketplaceId = "YourMarketplaceID";
18
19 RequestReportRequest reportRequestRequest = new RequestReportRequest();
20 reportRequestRequest.Merchant = merchantId;
21 reportRequestRequest.Marketplace = marketplaceId;
22 reportRequestRequest.ReportType = "_GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_";
23
24 RequestReportResponse requestResponse = service.RequestReport(reportRequestRequest);
25 Thread.Sleep(15000); //wait 15 seconds for order to process
26
27 GetReportListRequest listRequest = new GetReportListRequest();
28 listRequest.Merchant = merchantId;
29 listRequest.Marketplace = marketplaceId;
30 GetReportListResponse listResponse = service.GetReportList(listRequest);
31
32 GetReportListResult getReportListResult = listResponse.GetReportListResult;
33 List<ReportInfo> reportInfoList = getReportListResult.ReportInfo;
34 ReportInfo myReportInfo = reportInfoList[0];
35
36 GetReportRequest reportRequest = new GetReportRequest();
37 reportRequest.Merchant = merchantId;
38 reportRequest.Marketplace = marketplaceId;
39
40 String source = path + "\\XMLReport.xml";
41 reportRequest.ReportId = myReportInfo.ReportId;
42 reportRequest.Report = File.Open(source, FileMode.Create, FileAccess.ReadWrite);
43 service.GetReport(reportRequest);
44
45 GetReportRequestListRequest reportRequestListRequest = new GetReportRequestListRequest();
46 reportRequestListRequest.Marketplace = marketplaceId;
47 reportRequestListRequest.Merchant = merchantId;
48 List<ReportRequestInfo> myListzz = new List<ReportRequestInfo>();
49
50 GetReportRequestListResponse reportRequestListResponse = new GetReportRequestListResponse();
51 reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest);
52 GetReportRequestListResult reportRequestListResult = new GetReportRequestListResult();
53 reportRequestListResult = reportRequestListResponse.GetReportRequestListResult;
54 myListzz = reportRequestListResult.ReportRequestInfo;
55
56 while (myListzz[0].ReportProcessingStatus.ToString() != "_DONE_")
57 {
58 lblStatus.Text = "Waiting for Report";
59 Thread.Sleep(61000);
60 reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest);
61 reportRequestListResult = reportRequestListResponse.GetReportRequestListResult;
62 myListzz = reportRequestListResult.ReportRequestInfo;
2 String secretAccessKey = "YourSecretAccessKey";
3 MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
4 config.ServiceURL = "https://mws.amazonservices.com";
5 const string applicationName = "ApplicationName";
6 const string applicationVersion = "0.1a";
7
8 MarketplaceWebServiceClient service =
9 new MarketplaceWebServiceClient(
10 accessKeyId,
11 secretAccessKey,
12 applicationName,
13 applicationVersion,
14 config);
15
16 const string merchantId = "YourMerchantID";
17 const string marketplaceId = "YourMarketplaceID";
18
19 RequestReportRequest reportRequestRequest = new RequestReportRequest();
20 reportRequestRequest.Merchant = merchantId;
21 reportRequestRequest.Marketplace = marketplaceId;
22 reportRequestRequest.ReportType = "_GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_";
23
24 RequestReportResponse requestResponse = service.RequestReport(reportRequestRequest);
25 Thread.Sleep(15000); //wait 15 seconds for order to process
26
27 GetReportListRequest listRequest = new GetReportListRequest();
28 listRequest.Merchant = merchantId;
29 listRequest.Marketplace = marketplaceId;
30 GetReportListResponse listResponse = service.GetReportList(listRequest);
31
32 GetReportListResult getReportListResult = listResponse.GetReportListResult;
33 List<ReportInfo> reportInfoList = getReportListResult.ReportInfo;
34 ReportInfo myReportInfo = reportInfoList[0];
35
36 GetReportRequest reportRequest = new GetReportRequest();
37 reportRequest.Merchant = merchantId;
38 reportRequest.Marketplace = marketplaceId;
39
40 String source = path + "\\XMLReport.xml";
41 reportRequest.ReportId = myReportInfo.ReportId;
42 reportRequest.Report = File.Open(source, FileMode.Create, FileAccess.ReadWrite);
43 service.GetReport(reportRequest);
44
45 GetReportRequestListRequest reportRequestListRequest = new GetReportRequestListRequest();
46 reportRequestListRequest.Marketplace = marketplaceId;
47 reportRequestListRequest.Merchant = merchantId;
48 List<ReportRequestInfo> myListzz = new List<ReportRequestInfo>();
49
50 GetReportRequestListResponse reportRequestListResponse = new GetReportRequestListResponse();
51 reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest);
52 GetReportRequestListResult reportRequestListResult = new GetReportRequestListResult();
53 reportRequestListResult = reportRequestListResponse.GetReportRequestListResult;
54 myListzz = reportRequestListResult.ReportRequestInfo;
55
56 while (myListzz[0].ReportProcessingStatus.ToString() != "_DONE_")
57 {
58 lblStatus.Text = "Waiting for Report";
59 Thread.Sleep(61000);
60 reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest);
61 reportRequestListResult = reportRequestListResponse.GetReportRequestListResult;
62 myListzz = reportRequestListResult.ReportRequestInfo;
63 }
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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
2012-11-29 c# ThreadPool 判断子线程全部执行完毕的四种方法