代码之家  ›  专栏  ›  技术社区  ›  sangeeta

如何在改造中以原始形式发送post请求和数据?

  •  0
  • sangeeta  · 技术社区  · 6 年前

    enter image description here

    我想发送一个原始形式的身体在上述格式的数据。数据类型应为“JSON(application/JSON)”,标题应包含“application/JSON”作为内容类型。

    我试过用这种方法,但对我无效。

    public interface AddData {
        @POST("/Api/")
        Call<String> postData(@Header("Content-Type") String content_type,@Body JSONObject body);
    }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Brijesh Joshi    6 年前

    使用@标题作为批注

    @Headers("Content-Type: application/json") @POST("/Api/") Call<String> getUser(@Body JSONObject body);

    提到 https://github.com/square/retrofit/issues/1587