【问题标题】:Amazon Seller Central - SP-API - Create a feed document - InvalidInput亚马逊卖家中心 - SP-API - 创建提要文档 - InvalidInput
【发布时间】:2021-04-26 18:43:01
【问题描述】:

尝试创建提要文档 (here),我收到 InvalidInput 错误代码。 身份验证效果很好(我尝试了其他端点并且它有效)所以我认为标头不是问题。

这是我的示例代码:

endpoint = 'https://sellingpartnerapi-eu.amazon.com/feeds/2020-09-04/documents'
body = {
    "contentType": "text/tab-separated-values; charset=UTF-8"
}
resp = requests.post(
    endpoint,
    auth=self.amazon_auth.auth, 
    headers=self.amazon_auth.headers,
    json=body
)
return resp

响应码:

{'errors': [{'code': 'InvalidInput',
   'message': 'Invalid Input',
   'details': ''}]}

我还尝试使用不同的contentType 和字符集(如text/plain),但收到相同的错误代码!

这是Submit feed tutorial的第一步。

我正在尝试创建提要,以便获得 cartonIds 以下载我在亚马逊卖家中心创建的货件的标签。

任何提示,帮助都非常受欢迎!

谢谢!

【问题讨论】:

  • 您好,请问您有解决办法吗?
  • 嗨,我没有,为此花了太多时间——可能会根据开发优先级再次选择这个话题。现在我们正在解析导出的 csv 文件并完成工作。祝你好运! :)

标签: python amazon amazon-mws amazonsellercentral


【解决方案1】:

我通过以下方式解决了这个问题:

requests.post(data=json.dumps(body))

还要确保您也将正文传递给签名

【讨论】:

    【解决方案2】:

    我使用 RestSharp restRequest1.AddParameter(....);给了我和你一样的错误 Invalid Input 但下面的行给了我一个响应值 restRequest1.AddJsonBody(new { contentType = "text/xml; charset=UTF-8" }); 它将obj序列化为json格式并添加到请求体中。

    【讨论】:

    • 你能告诉我你的请求是什么样子的吗?像所有标题、正文和网址一样打印我吗?我也尝试了 text/xml 但相同的响应。我用的是python,你用的是C#?
    • 类型:- RequestBody {application/json={"contentType":"text/xml; charset=UTF-8"}} 类型:- httpHeader {x-amz-access-token=Atza| XXXXX...} {x-amz-security-token=XXXXXXX} {X-Amz-Date=20210120T205817Z} {host= sellpartnerapi-XXXXX.amazon.com} {Authorization=AWS4-HMAC-SHA256 Credential=/20210120/XXXXX -west-1/execute-api/aws4_request, SignedHeaders=host;x-amz-access-token;x-amz-date;x-amz-security-token, Signature=XXX}
    • 我不认为这里的问题是内容类型,而是它是如何保存在 RequestBody 中的,你可以看到它是一个应用程序/json
    • @JJohn 我用这种方式遇到了错误The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details
    【解决方案3】:

    C# 中的这段代码 sn-p 对我有用,我成功上传了一个提要

    我的上传方式:

    private static bool UploadFile(byte[] encrypted, string url)
    {
        bool isUploaded = false;
    
        var contentType = "text/tab-separated-values; charset=UTF-8";
    
        var parameter = new Parameter
        {
            Name = contentType,
            Value = encrypted,
            Type = ParameterType.RequestBody
        };
    
        var restRequest = new RestRequest(Method.PUT);
        restRequest.Parameters.Add(parameter);
    
        var restClient = new RestClient(url);
        var response = restClient.Execute(restRequest);
    
        isUploaded = response.StatusCode == System.Net.HttpStatusCode.OK;
    
        return isUploaded;
    }
    

    【讨论】:

    • 您的回答确实没有解决有关 createfeeddocument 的最初问题。为了能够处理上传的文件,您需要创建 documentId 和 OP,就像我的情况有问题一样。虽然当我对 ORDERS 使用相同的授权时,我的访问被拒绝了。您能否提供更多代码来展示您如何从创建中获得验证文档 ID?另外,你用的是什么网址?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-23
    • 1970-01-01
    • 2012-09-23
    • 2016-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多