2016-08-05 22 views
0

Ich versuche, Daten als Json zu einem api mit Jsoup zu schreiben, aber die api gibt mir eine Fehlermeldung,Jsoup sendet application/x-www-form-urlencoded statt json

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

Die Jsoup Anfrage:

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(); 

Es ist möglich, dass Jsoup den Inhaltstyp nicht geändert hat? Ich habe auch versucht, zuerst die requestBody, dann den Inhaltstyp, aber es ist das gleiche.

Antwort