HTTP 415 while sending JSON object using POST

前端 未结 2 1553
我在风中等你
我在风中等你 2021-02-12 12:56
import java.io.BufferedReader;    
import java.io.InputStreamReader;    
import java.net.HttpURLConnection;    
import java.net.URL;    
import java.io.DataOutputStream;         


        
2条回答
  •  半阙折子戏
    2021-02-12 13:24

    The HTTP response code you get is

    415 Unsupported Media Type
    

    This means that the server can not handle the format you sent to it. Your HTTP request sets this header:

    Content-Type: application/x-www-form-urlencoded
    

    This is the content type sent by a browser if a form is submitted. If you want to send JSON, use this header:

    Content-Type: application/json
    

提交回复
热议问题