I am trying to upload an image to the Twitter-API, which requires a multipart/form-data oAuth-signed POST request. However there seems to be some kind of mistake in my code, as I'm getting 503 Errors everytime I try to call the function. Which should be a "Temporarily unavailable" error, but it is constant over different times of the day and apparently other people had the same problem with uploading media via the Twitter-API.
Following some examples I found, I am currently building the multipart header like this:
postData := '--', boundary, String crlf,
'Content-Disposition: form-data; filename="upload.png"; name="media"', String crlf,
'Content-Type: image/png', String crlf,
'Content-Transfer-Encoding: base64', String crlf,
morphAsBinaryString, String crlf,
'--', boundary,'--', String crlf.
The actual httpPost command goes like this:
request := client httpPost: url
content: postData
type: 'multipart/form-data; boundary=', boundary
do:[:req | WebUtils oAuthSign: req url: url extra: extra using: personalOauthParams].
Is this the correct approach? Thanks in advance for any help.
UPDATE: As it turns out there was a String crlf missing in the line before the media data. Now I am getting an "Authentication Required" error. Other API-calls work without problem.