Oto-obong Eshiett
Oto-obong Eshiett

Reputation: 1679

How can i create a retrofit api method call that doesnt return a response

I am trying to create an api call that doesn't have a response with retrofit, but the call does not return any thing, so how do i handle it in Retrofit

i have a code like this :

    @POST("/message")
public Call<ResponseModel> SendMessageToSocketIOServer(@Body SocketIOMessageModel socketIOMessageModel);

but i tried this using void but with no result

 @POST("/message")
public Call<void> SendMessageToSocketIOServer(@Body SocketIOMessageModel socketIOMessageModel);

So how can i achieve handling a no response call api ?

Upvotes: 2

Views: 927

Answers (2)

Raj
Raj

Reputation: 194

You can use Call<ResponseBody> .Which indicates that you doesn't care about response body. But you can check the response is successful.

Upvotes: 1

nyarian
nyarian

Reputation: 4365

Just change Call<void> to Call<Void> (with uppercase V). All generic expect reference type, not primitive type or void.

Upvotes: 1

Related Questions