2016-08-05 28 views
0

我想數據作爲JSON發佈與Jsoup的API,但是API給了我一個錯誤說Jsoup發送應用程序/ x-WWW的形式了urlencoded,而不是JSON

There was an unexpected error (type=Unsupported Media Type, status=415). 
Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported 

的Jsoup要求:

Jsoup.connect(apiConfiguration.getHttpBaseAddress()+url) 
       .validateTLSCertificates(false) 
       .maxBodySize(0) 
       .timeout(180000) 
       .ignoreHttpErrors(true) 
       .header("Authorization", apiConfiguration.getLoginString()) 
       .header("Content-Type", "application/json") 
       .header("cache-control", "no-cache") 
       .method(Connection.Method.POST) 
       .requestBody(reqBodyStr)//POJO, parsed with Gson --> String 
       .execute(); 

這可能是Jsoup沒有改變內容類型?我也嘗試先設置requestBody,然後設置內容類型,但它是一樣的。

回答

相關問題