Getting Request body content using Retrofit 2.0 POST method

前端 未结 2 1396
遇见更好的自我
遇见更好的自我 2021-02-07 14:13

I have a requirement to get a request body and to perform some logic operations with Retrofit 2.0 before doing enque operation. But unfortunately I am not able to g

2条回答
  •  死守一世寂寞
    2021-02-07 14:38

    I too had the similar issue, I had set JSON as @Body type in retrofit, so the namevaluepair appears in front of the raw body, and it can be seen inside the interceptor. Even though if we log/debug the jsonObject.toString we see the request as correct without the namevaluepair presented.

    What i had done was by setting

    Call getResults(@Body JsonObject variable);
    

    and in the calling of the method i converted the JSONObject to JsonObject by

     new JsonParser().parse(model).getAsJsonObject();
    

提交回复
热议问题