Use php curl to call the interface provided by the other party and receive the following error message:
HTTP Status 415
The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Curl code snippets are as follows:
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_HEADER, FALSE );
Curl_setopt ($ ch, CURLOPT_NOBODY, FALSE );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, TRUE );
Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, TRUE );
Curl_setopt ($ ch, CURLOPT_AUTOREFERER, TRUE );
Curl_setopt ($ ch, CURLOPT_TIMEOUT, 120 );
Curl_setopt ($ ch, CURLOPT_POST, TRUE );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, json_encode ($ postData ));
$ Data = curl_exec ($ ch );
Curl_close ($ ch );
No problems were found in the description of the interface set in curl for multiple checks. The server on the other side uses Tomcat 7. At one time, it was suspected that the web configuration of the other side was incorrect. Later, I studied the document carefully, and mentioned that Response is the jason format document, but the Request Header information is not specified in the above curl, so try to add a header and solve the problem. The code is as follows:
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ("Content-Type: application/json; charset = utf-8 "));