System. The out. Println (" postFormUrlEecoded url="+ url);
System. The out. Println (" postFormUrlEecoded body="+ body);
Return request (restTemplate, url, MediaType. APPLICATION_FORM_URLENCODED HttpMethod. POST, the body, "");
}
Public static JSONObject request (RestTemplate RestTemplate, String url, MediaType MediaType, HttpMethod HttpMethod, String body, the Object... UriVariables) {
HttpHeaders HttpHeaders=new HttpHeaders ();
HttpHeaders. SetContentType (mediaType);
HttpEntity
ResponseEntity
Try {
Logger. The info (" {} {} request parameters, url, body);
ResponseEntity=restTemplate. Exchange (url, httpMethod, mapHttpEntity, String class, uriVariables);
} the catch (RestClientException e) {
e.printStackTrace();
return null;
}
If (responseEntity getStatusCodeValue ()==200) {
Logger. The info (" {} {} "request results, url, responseEntity. GetBody ());
Return a JSON. ParseObject (responseEntity getBody ());
} else {
Logger. Error (request {} "failure", url);
return null;
}
}
Org. Springframework. Web. Client. RestClientException: Error while extracting the response for the type [class Java. Lang. String] and the content type (application/json; charset=utf-8 16]. Nested exception is org. Springframework. HTTP. Converter. HttpMessageNotReadableException: JSON parse error: always deserialize the instance of ` Java lang. String ` out of START_OBJECT token; Nested exception is com. Fasterxml. Jackson. Databind. Exc. MismatchedInputException: always deserialize the instance of ` Java lang. String ` out of START_OBJECT token
At [Source: (PushbackInputStream); the line: 1, the column: 1)
The at org. Springframework. Web. Client. HttpMessageConverterExtractor. ExtractData (HttpMessageConverterExtractor. Java: 117)
The at org. Springframework. Web. Client. $ResponseEntityResponseExtractor RestTemplate. ExtractData (RestTemplate. Java: 995)
The at org. Springframework. Web. Client. $ResponseEntityResponseExtractor RestTemplate. ExtractData (RestTemplate. Java: 978)
The at org. Springframework. Web. Client. RestTemplate. The doExecute (RestTemplate. Java: 737)
The at org. Springframework. Web. Client. RestTemplate. Execute (RestTemplate. Java: 670)
At org. Springframework. Web. Client. RestTemplate. Exchange (579) RestTemplate. Java:
At com. Butech. Bmcporabvsrv. Util. RestTemplateUtil. Request (55) RestTemplateUtil. Java:
At com. Butech. Bmcporabvsrv. Util. RestTemplateUtil. PostFormUrlEecoded (RestTemplateUtil. Java: 22)
At com. Butech. Bmcporabvsrv. Support. Erp. ErpOpenApi. Login (ErpOpenApi. Java: 56)
CodePudding user response:
Check START_OBJECT's object is to realize the serial interfaceCodePudding user response:
//set to receive the return value format for jsonList
MediaTypeList. Add (mediaType);
HttpHeaders. SetAccept (mediaTypeList);
CodePudding user response:
Json parsing errors, interface the data returned is not standard json formatCodePudding user response:
Request header application/json means the foreground to background passing json dataCodePudding user response:
The body format is wrong