I'm testing SkyDrive's API using the following code:
Dim webRequest As HttpWebRequest = DirectCast(HttpWebRequest.Create("https://apis.live.net/v5.0/me/skydrive/files?access_token=" & Me.ACCESS_TOKEN), HttpWebRequest)
webRequest.Method = "POST"
webRequest.ContentType = "multipart/form-data; boundary=A300x"
webRequest.KeepAlive = True
webRequest.Timeout = 80000
Using streamWriter As New System.IO.StreamWriter(webRequest.GetRequestStream())
streamWriter.Write("--A300x\r\n")
streamWriter.Write("Content-Disposition: form-data; name=""file""; filename=""HelloWorld.txt""\r\n")
streamWriter.Write("Content-Type: application/octet-stream\r\n")
streamWriter.Write("\r\n")
streamWriter.Write("vooo")
streamWriter.Write("\r\n")
streamWriter.Write("--A300x--\r\n")
streamWriter.Close()
End Using
' response
Using webResponse As HttpWebResponse = DirectCast(webRequest, HttpWebRequest).GetResponse()
If webResponse.StatusCode() = HttpStatusCode.OK Then
Using streamReader As New System.IO.StreamReader(webResponse.GetResponseStream())
Throw New Exception(streamReader.ReadToEnd())
streamReader.Close()
End Using
End If
webResponse.Close()
End Using
Getting bad request (400). Access token and URL are verified and valid. any clue?
If you look at the response body (or use Fiddler to do the same) you'll find a JSON-formatted error message that explains exactly where the problem lies. My first guess is that the folder skydrive doesn't exist for this target user.