I'm using this URL to attempt to delete a file:
https://apis.live.net/v5.0/file.12ea4b6cbf3ee803.12EA4B6CBF3EE803!151
I'm using the DELETE method.
The return I get from the server is:
{
"error": {
"code": "request_body_invalid_media_type",
"message": "The Content-Type header 'text/plain; charset=UTF-8' isn't expected for this HTTP method."
}
}
I tried using application/json, but it didn't work either.
Why is OneDrive caring about the Content-Type in this case?
What Content-Type should I use?
There no information about Content-Type here:
http://msdn.microsoft.com/en-us/library/dn659743.aspx#delete_a_file
The Content-Type header is used to state the kind of content that is being sent in the body of the request. In the case of the DELETE requests you should not specify a request body, as you should not be transmitting one.
If you sent a Content-Type on a request that does not contain a body this could lead a service to get confused that it received a malformed request, which is why I believe you are seeing a 400 bad request response since the header is invalid in the Delete scenario.
Here is a request that I transmitted this evening which worked successfully:
DELETE https://apis.live.net/v5.0/file.8bf6ae9dbc6ca4c.8BF6AE9DBC6CA4C!39763 HTTP/1.1
Accept: */*
Authorization: bearer EwCAAq...BbWPszRgepabcSYljAQ==
Host: apis.live.net
Response:
HTTP/1.1 200 OK
Content-Length: 0
...