Error Code 189 update_with_media


#1

Currently writting my own library and currently having an issue with updating with media…

My request header

POST https://api.twitter.com/1.1/statuses/update_with_media.json HTTP/1.1
Authorization: OAuth oauth_consumer_key="...",oauth_nonce="...",oauth_signature="aOSAJsbpbcucWevFMmTi8xjr4as%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1370454773",oauth_token="...",oauth_version="1.0"
Content-Type: multipart/form-data; charset=utf-8; boundary=13704296019969056
Host: api.twitter.com
Content-Length: 62465
Expect: 100-continue

--13704296019969056
Content-Disposition: form-data; name="status"

123456
--13704296019969056
Content-Type: application/octet-stream
Content-Disposition: form-data; name="media[]"

<Binary ImageData>
--13704296019969056--

which returns error creating status

here is the code behind that creates the body

            Dim hwr = Net.WebRequest.Create(targetUrl)
            hwr.Method = "POST"
            hwr.Headers.Add("Authorization", oAuthHeaderParams)
            Dim boundary As String = DateTime.Now.Ticks - New DateTime(1970, 1, 1).Ticks

            hwr.ContentType = "multipart/form-data; boundary=" & boundary
            Dim body As New StringBuilder
            Dim mediaBytes(media.Length) As Byte
            media.Read(mediaBytes, 0, media.Length)
            body.Append("--" & boundary & vbCrLf)
            body.Append("Content-Disposition: form-data; name=""status""" & vbCrLf & vbCrLf)
            body.Append(status & vbCrLf)
            body.Append("--" & boundary & vbCrLf)
            body.Append("Content-Disposition: form-data; name=""media[]""" & vbCrLf)
            body.Append("Content-Transfer-Encoding: application/octet-stream" & vbCrLf & vbCrLf)
            body.Append(Text.Encoding.UTF8.GetString(mediaBytes) & vbCrLf)
            body.Append("--" & boundary & "--")
            hwr.ContentLength = Text.Encoding.UTF8.GetByteCount(body.ToString)
            Dim swr As New StreamWriter(hwr.GetRequestStream())
            swr.Write(body.ToString)
            swr.Close()
            Try
                Return New StreamReader(hwr.GetResponse.GetResponseStream).ReadToEnd
            Catch ex As Net.WebException
                Throw New SocialMediaExceptions.SocialMediaException(New StreamReader(ex.Response.GetResponseStream).ReadToEnd, ex)
            End Try

#2

Missing filename in line with ‘media[]’ in request header