% character not handle well in direct_messages and statuses udpate


#1

I found a issue in the direct_messages/new if there has % character in the text. Here is my test text:

plain: Random status update: 1797744914%
encode: Random%20status%20update%3A%201797744914%25

The API returns HTTP/1.1 401 Unauthorized error.

{"errors":[{"message":"Could not authenticate you","code":32}]}

I know my authentication is correct because once I remove the % character. But once I add a space after the %, it works.

And I found the same issue on statuses/update method as well.

Is this a bug of the REST API?

Cheers,


#2

Maybe your library is tampering with the encoding somehow? I’m able to issue such direct messages ending with a “%” character easily enough:

POST body:

text=hello%20and%20%25&screen_name=episod

Signature base string:

POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fdirect_messages%2Fnew.json&oauth_consumer_key%3D5aA6oofBOFAwN4tfmEYWjg%26oauth_nonce%3DPKf4PdWB1mO6DKVI01tpfLXINZIHxjF6sNkzTyw8iw%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1377105867%26oauth_token%3D119476949-oYGCs2M5duG5QalbOAK2YUZh8zG3ur7DPYo5qIFN%26oauth_version%3D1.0%26screen_name%3Depisod%26text%3Dhello%2520and%2520%2525

The resulting direct message JSON object contains the correct text:

“text”:“hello and %”


#3

I found out that the % will work if I pass the oAuth info in the post body instead of header like you do. And more interesting is that I running the same code today morning and everything works fine even oAuth is pass in the header cookie.

It seems Twitter team fix the issue last night but not telling everybody.