HTTP GET with request body RETROFIT

前端 未结 5 1967
轻奢々
轻奢々 2021-02-06 23:45

I am using Retrofit to make api calls in my android application. I have to submit a @Body of JSON

@GET(\"api/\")
void getData(@Body UserPostRequestBody request)
         


        
5条回答
  •  死守一世寂寞
    2021-02-06 23:56

    To send data along with your Get Request you can do the following:

    //sending data as a url parameter
    @GET("/group/{id}/users")
    List groupList(@Path("id") int groupId);
    

    as said in this SO answer, Server semantics for GET, however, are restricted such that a body, if any, has no semantic meaning to the request- Roy Fielding.

提交回复
热议问题