加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 报告API的MWS GetReport函数返回null?

发布时间:2020-12-16 01:46:34 所属栏目:百科 来源:网络整理
导读:我正在尝试提取FBA出货数据报告.我有一个正在运行的应用程序,成功地从亚马逊拉出Unshipped Orders.因此,基本上我采用了该代码并将其更改为我需要它为FBA装运订单执行的操作.我几乎没有更改工作代码来获取报告,现在GetReport函数返回null,我不知道为什么.我传
我正在尝试提取FBA出货数据报告.我有一个正在运行的应用程序,成功地从亚马逊拉出Unshipped Orders.因此,基本上我采用了该代码并将其更改为我需要它为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);

然后,它会将报告写入该文件.所以,你可以在那里看到你的报告.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读