Invalid parameter value on GetMyFeesEstimate - amazon-mws

I am trying to send a request to GetMyFeesEstimate using the Amazon MWS service (doc):
POST /Products/2011-10-01/?FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId=XXXXXXXXXXXXXX&FeesEstimateRequestList.FeesEstimateRequest.1.IdType=EAN&FeesEstimateRequestList.FeesEstimateRequest.1.IdValue=6950029002582&FeesEstimateRequestList.FeesEstimateRequest.1.IsAmazonFulfilled=true&FeesEstimateRequestList.FeesEstimateRequest.1.Identifier=request1&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.CurrencyCode=USD&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.Amount=30.00&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.CurrencyCode=USD&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.Amount=3.99&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Points.PointsNumber=0&AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX&Action=GetMyFeesEstimate&MWSAuthToken=123&SellerId=XXXXXXXXXXXXXX&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-06-23T14:58:28Z&Version=2011-10-01&Signature=cPG3pcI0OT9b0GzkfTVPuBJ+fKo= HTTP/1.1
Host: mws.amazonservices.es
Cache-Control: no-cache
Postman-Token: 953f5ba5-d6c3-481a-5e7d-7bfa6ba2adcd
Content-Type: application/x-www-form-urlencoded
But I am receiving this response:
<?xml version="1.0"?>
<ErrorResponse xmlns="https://mws.amazonservices.com/">
<Error>
<Type>Sender</Type>
<Code>InvalidParameterValue</Code>
<Message>Invalid query string provided - FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId=XXXXXXXXXXXXXX&FeesEstimateRequestList.FeesEstimateRequest.1.IdType=EAN&FeesEstimateRequestList.FeesEstimateRequest.1.IdValue=6950029002582&FeesEstimateRequestList.FeesEstimateRequest.1.IsAmazonFulfilled=true&FeesEstimateRequestList.FeesEstimateRequest.1.Identifier=request1&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.CurrencyCode=USD&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.Amount=30.00&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.CurrencyCode=USD&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.Amount=3.99&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Points.PointsNumber=0&AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX&Action=GetMyFeesEstimate&MWSAuthToken=123&SellerId=XXXXXXXXXXXXXX&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-06-23T14:58:28Z&Version=2011-10-01&Signature=cPG3pcI0OT9a0GzkfTVPuBJ+fKo= is not valid; the value of a query string parameter may not contain a &apos;=&apos; delimiter</Message>
</Error>
<RequestID>506e7ce6-1f5f-4e4f-afc1-e2defa175a4d</RequestID>
</ErrorResponse>

As Jad said, the IdType can only be ASIN and SellerSKU, this needs to be changed.
But the exception here is the query string is invalid, as you can see in the error message. There should not be '=' in the query string. I see it in your signature, that may be the problem.

Related

BizTalk incorrect request (multipart form data)

We need to send a file of xbrl format (a type of xml) to a receiving system. However, the receiving system requires that we are sending some form data as well. Regarding the xbrl file we need to send with it a form data, name="data".
Regarding the second part, we need to send an email to the system via form data. And that is name="email".
(I'll be the first to admit that I really do not understand form data at all so I cant explain much better than this).
I have a custom pipeline and in the encode stage I have put my pipeline component (the entire Execute method is down below) and after that a MIME/SMIME component (standard Microsoft).
Take a look at how the request looks like when it is being sent from Postman (and fully accepted by the receiving system):
Content-Type: multipart/form-data; boundary=--------------------------035085236562027409735938
Content-Length: 299420
----------------------------035085236562027409735938
Content-Disposition: form-data; name="data"; filename="Dk_{5AA9547A-E103-40CD-A2F4-6B77F010E570}.xbrl"
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8"?>
<!- ---- Lots of removed xbrl ---- ->
</xbrli:xbrl>
----------------------------035085236562027409735938
Content-Disposition: form-data; name="email"
Content-Type: text/plain
test#test.com
----------------------------035085236562027409735938--
Now what you see below is what we have managed to achieve this far:
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="_E9E8D52C-4722-488D-9FEC-713446D4A5C4_"
--_E9E8D52C-4722-488D-9FEC-713446D4A5C4_
MIME-Version: 1.0
Content-Type: application/xml; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Content-ID: {E8CA3F1A-F953-4FFB-A054-DEB8466A5D86}
Content-Description: body
<?xml version="1.0" encoding="utf-8"?>
<!- ---- Lots of removed xbrl ---- ->
</xbrli:xbrl>
--_E9E8D52C-4722-488D-9FEC-713446D4A5C4_
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-ID: {3B35ECAC-990D-458C-8E7E-9C178CA99988}
Content-Description: email
Content-Disposition: attachment; filename="=?utf-8?B?QXR0YWPobWVudDF=?="
test#test.com
--_E9E8D52C-4722-488D-9FEC-713446D4A5C4_--
Now, a quick comparison reveals that we are closing in on the solution. The first important issue must be that the Content-Type (first part below MIME-version: 1.0) is becoming multipart/mixed when we need multipart/form-data.
Second issue is in the Content-Disposition which for both parts does not, at all, look like expected.
Please take a look at my pipeline component. What you see is the entire code from the Execute. Since formDataPart.Data only takes a stream I have a method that translates a string to a stream (MemoryStream).
// Variables
var outMsg = pContext.GetMessageFactory().CreateMessage();
outMsg.Context = PipelineUtil.CloneMessageContext(pInMsg.Context);
outMsg.Context.Promote("ContentType", "http://schemas.microsoft.com/BizTalk/2003/http-properties", "multipart/form-data;");
// Process xbrl file
var msgPart = pContext.GetMessageFactory().CreateMessagePart();
msgPart.PartProperties.Write("FileName", "http://schemas.microsoft.com/BizTalk/2003/mime-properties", "SomeID.xbrl");
msgPart.PartProperties.Write("ContentDescription", "http://schemas.microsoft.com/BizTalk/2003/mime-properties", "xml");
//msgPart.PartProperties.Write("ContentTransferEncoding", "http://schemas.microsoft.com/BizTalk/2003/mime-properties", "7bit");
msgPart.Data = pInMsg.BodyPart.Data;
msgPart.ContentType = "application/xml";
msgPart.Charset = "UTF-8";
outMsg.AddPart("data", msgPart, true);
// Form data (email)
var formDataPart = pContext.GetMessageFactory().CreateMessagePart();
formDataPart.ContentType = "text/plain";
formDataPart.Charset = "utf-8";
formDataPart.PartProperties.Write("ContentType", "http://schemas.microsoft.com/BizTalk/2003/http-properties", "form-data;");
formDataPart.Data = GenerateStreamFromString("test#test.com");
outMsg.AddPart("email", formDataPart, false);
return outMsg;
Does anybody know whow we can achieve this? I can also mention that we are using the MIME/SMIME component after this custom pipeline component.
I really think that the solution from Greg Forsythe would be the best solution since I would have total control over the message but I have no idea how to translate that into actual code.
Greg_suggestion
UPDATE: After so many trials and not coming anywhere we decided to ditch the above solution and go with Gregs solution instead. There is an issue there so I hope some C# guru can help us out. Please take a look at the new question if you are struggling with the form data request issue.
Second attempt here

The parsing of an eml with javamail doesn't recognize properly nested messages

I'm implementing an .eml parser using Javamail 1.5.6, I've started copying from msghow.java a sample provided within javamail.
I'm testing an eml which contains as attachment another eml, this is an extract:
MIME-Version: 1.0
Date: Tue, 30 Apr 2019 16:20:45 +0200
Message-ID: <CA+fLqEW8TUfSxih9DTp2WXa63pS7wf1eZiro_9k1XS4AShN5Zg#mail.gmail.com>
Subject: Message with an eml as attachment
From: a b <ab#gmail.com>
To: cd#pec.cd.it
Content-Type: multipart/mixed; boundary="00000000000057f76c0587c01bc9"
--00000000000057f76c0587c01bc9
Content-Type: multipart/alternative; boundary="00000000000057f7670587c01bc7"
--00000000000057f7670587c01bc7
Content-Type: text/plain; charset="UTF-8"
Hello guys,
this is a simple message from a not certified account, it contains only one
attachment, an eml message
--00000000000057f7670587c01bc7
Content-Type: text/html; charset="UTF-8"
<div dir="ltr">Hello guys,<div><br></div><div>this is a simple message from a not certified account, it contains only one attachment, an eml message</div></div>
--00000000000057f76c0587c01bc9
Content-Type: message/rfc822; name="Cena zerebao.eml"
Content-Disposition: attachment; filename="Cena zerebao.eml"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_jv3vpu760
Content-ID: <f_jv3vpu760>
WC1Ob3Rlcy1JdGVtOiBGcmksIDYgSnVsIDIwMTggMTc6NDA6MDAgKzAyMDA7DQogdHlwZT00MDA7
IG5hbWU9T3JpZ2luYWxNb2RUaW1lDQpYLU5vdGVzLUl0ZW06IE1lbW87DQogbmFtZT1Gb3JtDQpY
LU5vdGVzLUl0ZW06IFN0ZE5vdGVzTHRyMjU7DQo.... and so on
Javamail recognizes that eml but when I get its subject, date, body, attachments and so on, they all are null.
msghow.java itself doesn't see them.
Before javamail I implemented my parser with mime4j and I haven't this problem, but now I would like to parse emls using only javamail if possible
From the javadocs describing the mail.mime.allowencodedmessages property:
The MIME spec does not allow body parts of type message/* to be encoded. The Content-Transfer-Encoding header is ignored in this case. Some versions of Microsoft Outlook will incorrectly encode message attachments. Setting this System property to "true" will cause the Content-Transfer-Encoding header to be honored for message attachments. The default value of this property is false.

HTTP POST mutli part "BAD REQUEST"

I'm trying to upload a file using POST
here's my request :
POST /upload.php HTTP/1.1
Host: localhost
Content-Type: multipart/form-data; boundary=---------------------------552335022525
Content-Length: 192
-----------------------------552335022525
Content-Disposition: form-data; name="userfile"; filename="12.txt"
Content-Type: text/plain
blabla
-----------------------------552335022525--
Using HTTP live headers firefox plugin everything works
but when putting it a char *buffer and send it with winsocksapi I get 400 Bad Request error
You need a blank line between the headers and the payload.
Content-Length: 192
-----------------------------552335022525
This is part of the HTTP protocol. HTTP request headers end with the first empty line (CR-LF by itself.) What you are sending is resulting in the string
-----------------------------552335022525
being taken (along with the following two lines) as a request header which, of course, it isn't. The server can't make head or tail of that, so it responds with 400 Bad Request.
Also, sending the Content-length is not necessary with multipart/form-data, nor even a good idea, as the wrong value could create problems. The MIME multipart format is self describing.

How to define received datatype, in backbone.js fetch()?

fetch data from server returns me json data as a string datatype rather than as application/json datatype, as a result the collection does not get refreshed.
I have tried giving the jquery.ajax option contentType:"application/json" to the fetch options, but still does not work.
how can i make it work? do i send a mimetype from the server? if so, how?
i am using json_encode on the data sent.
preloader.fetch({
contentType:'application/json'
});
preloader is an instance of my collection.
edit:
my template for a subview was not getting detected as i had kept it out of the masterview's $el element, corrected it, and now i am getting underscore.js error, that
str is null in
str.replace(/\\/g, '\\\\') //at line 913
is this because the backbone app is not taking it as a json object?
Request headers
Connection close
Content-Type text/html
Date Thu, 12 Apr 2012 13:00:58 GMT
Server Apache
Transfer-Encoding chunked
Vary Accept-Encoding
Response headers
has the line
Accept application/json, text/javascript, */*; q=0.01
means it is a json, then what is the problem?
I think the contentType option is for the request (your request).
Try dataType:"json".

Are GET request header fields and values case-sensitive?

I'm working on a programing assignment regarding using GET request.
I am using C.
I wonder if any headers fields and values of GET packet have to be capitalized?
For example:
GET / HTTP/1.1
Connection: Keep-Alive
vs
get / HTTP/1.1
connection: keep-alive
HTTP method names are case-sensitive:
The Method token indicates the method
to be performed on the resource
identified by the Request-URI. The
method is case-sensitive.
HTTP header names are case-insensitive.

Resources