1

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!

MC Emperor
  • 22,334
  • 15
  • 80
  • 130
ky_aaaa
  • 290
  • 3
  • 10
  • Hi, Did you get any solution of this? – Ashok Damani May 24 '21 at 15:27
  • Hi, I didn't, spent too much time for it - probably will pick up this topic again dep on development priority. For now we're parsing export csv files and doing the work. Good luck! :) – ky_aaaa May 25 '21 at 10:02

3 Answers3

2

I solved this issue by:

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

Also make sure you pass the body for signing as well

0

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.

J John
  • 21
  • 2
  • Can you show me how your request looks like, print me like all headers, body and url? I also tried with text/xml but same response. I'm using python and you use C#? – ky_aaaa Jan 22 '21 at 13:33
  • Type :- RequestBody {application/json={"contentType":"text/xml; charset=UTF-8"}} Type :- httpHeader {x-amz-access-token=Atza|XXXXX...} {x-amz-security-token=XXXXXXX} {X-Amz-Date=20210120T205817Z} {host=sellingpartnerapi-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} – J John Jan 24 '21 at 21:03
  • I dont think the problem here is the content type but how its saved in the RequestBody as u can see for me its an application/json – J John Jan 24 '21 at 21:08
  • @JJohn I am getting below error with this way `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` – Ashok Damani May 24 '21 at 15:31
-1

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;
}
Ante
  • 31
  • 2
  • Your answer really does not address the initial question regarding createfeeddocument. To be able to process an uploaded file you need to create the documentId and the OP, like my situation was having issues. Mine is accessed denied though when I use the same authorization for ORDERS it works. Can you provide more code to show how you got a valida documentId from the create? Also, what url did you use? – j.hull Jun 23 '21 at 15:44