Amazon Seller Central - SP-API - 创建 feed 文档 - InvalidInput

问题描述 投票:0回答:3

尝试创建 feed 文档(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
)但我收到相同的错误代码!

这是提交提要教程的第一步。

我正在尝试创建提要,这样我就可以

cartonIds
下载我在亚马逊卖家中心创建的货件的标签。

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

谢谢!

python amazon-mws amazonsellercentral
3个回答
1
投票

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

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

还要确保你也通过身体进行签名


0
投票

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


-1
投票

这个 C# 代码片段对我有用,我成功上传了一个 feed

我的上传方式:

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;
}
© www.soinside.com 2019 - 2024. All rights reserved.