Java – HTTP get and request body retrofit

I am using retrofit to make API calls in my Android application

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

I received an error message

retrofit.RetrofitError: apiCall: Non-body HTTP method cannot contain @Body or @TypedOutput.

Do you have any ideas

Solution

To send data and get requests, you can do the following:

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

As shown in 07 / 07, the server semantics of get is limited, so the body (if any) has no semantic meaning to the request - Roy Fielding

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>