Authorization failed while sending a multipart/form-data in New Direct Message

restapi
directmessages
authorization
error-codes

#1

Hi,
I have a lot of difficulties in communication with endpoint Direct Message/New.
I am sending a multipart/form-data from Java using AsyncRestTemplate. The header is set to: “Content-Type=multipart/form-data”.
I followed the instruction for calculating a signature and I included body parameters to this calculation. All parameters where percent encoded.
When calculation is done and Authorization header is produced I just send it (together with content-type) along with the body in UTF-8 to Twitter backend, and I am getting “Could not authenticate you.” with code 32.
What can be the problem?


#2

Ok.
I will reply to my own post as I have already tested my solution and surprisingly… the mistake is in Twitter Documentation.

Documentation says:

Next, gather all of the parameters included in the request. There are two such locations for these additional parameters - the URL (as part of the querystring) and the request body.

Which is not true.
I removed body parameter from being taken into account while calculating the signature and everything works like a charm.
My suggestion is to not trust the documentation but experiment with Twitter REST API.