Amazon Seller Central - SP-API - Create a feed document - InvalidInput

拜拜、爱过 提交于 2021-02-11 12:29:32

问题


Trying to create feed document (here ) and I'm getting InvalidInput error code. Authentication works well (I tried other endpoints and it works) so I think headers are not the issue.

Here is my sample code:

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

Response code:

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

I was also trying to use different contentType and charset (like text/plain) but I receive same error code!

This is first step of Submit feed tutorial.

I'm trying to create feed so I can get cartonIds to download labels for a shipment I created over Amazon Seller Central.

Any hint, help is more than welcome!

Thanks!


回答1:


I use RestSharp restRequest1.AddParameter(....); gave me the same error as yours Invalid Input but the below line gave me a response value restRequest1.AddJsonBody(new { contentType = "text/xml; charset=UTF-8" }); It serializes obj to json format and adds it to the request body.




回答2:


This code snippet in C# worked for me, i successfully uploaded a feed

My upload method:

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;
}


来源:https://stackoverflow.com/questions/65842779/amazon-seller-central-sp-api-create-a-feed-document-invalidinput

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!