I'm trying to upload a file with some metadata to google drive
heres my code basically:
Sub DriveMultiUpload(Bytes As Byte(), Name As String)
SetAuthHeaders("https://www.googleapis.com/auth/drive")
Dim mp = New MultipartFormDataContent
mp.Add(New StringContent(Name), "name")
mp.Add(New ByteArrayContent(Bytes))
Dim pb = mp.ReadAsByteArrayAsync.Result
Headers("Content-Type") = "multipart/related"
Dim response As Byte()
Dim ret = New WebInfo(Of String)
Try
response = UploadData("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", "POST", pb)
Catch ex As WebException
If ex.Response IsNot Nothing Then ret.Result = New StreamReader(ex.Response.GetResponseStream).ReadToEnd
End Try
End Sub
The error I'm getting is:
Bad content type. Please use multipart.
[BTW, I tried debugging in Fiddler, but
- this request doesnt show up,
- when Fiddler is open, the response is empty alltogether]
As you see in the code, i AM using multipart as the content-type
What i find odd though is that as soon as the uploaddata returns, the Headers does not contain any content-type at all anymore, so maybe this might be the issue?
please advise