c# - 报告 API 的 MWS GetReport 函数返回空值?

标签 c# amazon-mws

我正在尝试提取 FBA 装运数据报告。我有一个正在运行的应用程序,它成功地从亚马逊提取未发货的订单。所以基本上我拿了那个代码并将其更改为我需要它为 FBA 发货订单做的事情。我几乎没有更改工作代码来获取报告,现在 GetReport 函数返回 null,我不知道为什么。我正在传递来自亚马逊系统的 ReportId。

如果有人可以仔细阅读代码,看看我是否传递了空对象或其他东西。

RequestReportRequest reportRequestRequest = new RequestReportRequest();
reportRequestRequest.Merchant = merchantId;
reportRequestRequest.Marketplace = marketplaceId;
reportRequestRequest.ReportType = "_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_";
reportRequestRequest.StartDate = DateTime.Now.AddDays(-2);
reportRequestRequest.EndDate = DateTime.Now;

RequestReportResponse requestResponse = service.RequestReport(reportRequestRequest);
Thread.Sleep(15000);
Console.WriteLine(requestResponse.RequestReportResult.ReportRequestInfo.ReportProcessingStatus);
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_")
{
    Thread.Sleep(20000);
    reportRequestListResponse = service.GetReportRequestList(reportRequestListRequest);
    reportRequestListResult = reportRequestListResponse.GetReportRequestListResult;
    myListzz = reportRequestListResult.ReportRequestInfo;

}
GetReportListRequest listRequest = new GetReportListRequest();
listRequest.Merchant = merchantId;
listRequest.Marketplace = marketplaceId;
listRequest.ReportRequestIdList = new IdList();
listRequest.ReportRequestIdList.Id.Add(requestResponse.RequestReportResult.ReportRequestInfo.ReportRequestId);

GetReportListResponse listResponse = service.GetReportList(listRequest);


//MessageBox.Show(listResponse.GetReportListResult.ReportInfo.ToString());
GetReportListResult getReportListResult = listResponse.GetReportListResult;

GetReportRequest reportRequest = new GetReportRequest();
reportRequest.Merchant = merchantId;
reportRequest.Marketplace = marketplaceId;
reportRequest.WithReportId(getReportListResult.ReportInfo[0].ReportId);


GetReportResponse reportResponse = new GetReportResponse();

{
    reportResponse = service.GetReport(reportRequest); // <=== ERROR!!!!
}
catch (MarketplaceWebServiceException e)
{
    Console.WriteLine(e);
}
StreamReader sr = new StreamReader(reportRequest.Report);
Console.WriteLine(sr.ReadToEnd());
sr.Close();

最佳答案

在这一行之后:

GetReportResponse reportResponse = new GetReportResponse(); 

您必须指定一个报告文件,如下所示:

reportRequest.Report = File.Open("C:\\AmazonReport.csv", FileMode.OpenOrCreate, FileAccess.ReadWrite);

然后,它将报告写入该文件。 因此,您可以在那里查看您的报告。

关于c# - 报告 API 的 MWS GetReport 函数返回空值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7047420/

相关文章:

C# 在 #if DEBUG 中使用语句但不运送程序集

amazon-web-services - 在亚马逊 mws 中,在哪里可以获取买家信息,例如买家电子邮件、姓名等以进行待处理订单或取消订单

amazon-mws - 有什么方法可以从亚马逊 MWS 获取本地货币的结算数据吗?

php - 获取 30 天前的日期并转换为 iso8601 格式

java - 亚马逊 mws 能够注意到受限产品

c# - 键盘向上移动时屏幕无法正确移动 - android

c# - 将数据上传到 Windows Azure 时收到 409 错误

c# - .NET PropertyInfos 的平等

php - 使用MWS获取商品信息时重新定义参数$quotaMax报错

c# - 继承流;在 Read() 中缓冲