試圖調用Dropbox API v2。Dropbox API如何在RestRequest中設置內容類型
Dim client = New RestClient("https://api.dropboxapi.com/2/")
Dim request = New RestRequest("files/search", Method.POST)
request.AddHeader("Authorization", "Bearer " & MYTOKEN)
request.AddHeader("Content-Type", "application/json")
'request.RequestFormat = DataFormat.Json
'request.JsonSerializer.ContentType = "application/json; charset=utf-8;"
'request.AddParameter("Content-Type", "application/json")
request.AddParameter("path", "")
request.AddParameter("query", "my file")
request.AddParameter("start", "0")
request.AddParameter("max_results", "1")
request.AddParameter("mode", "filename")
Dim res = client.Execute(request)
總是返回
Error in call to API function "files/search": Bad HTTP "Content-Type" header: "application/x-www-form-urlencoded". Expecting one of "application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack"
試過註釋掉的代碼行,但還是同樣的反應。任何線索?
從代碼猜測,但是這個Visual Basic,你使用[RestSharp](http://restsharp.org/)? – smarx