how to POST parameters to server using retrofit2?

i want to POST data from android to server side using retrofit2 like : https://192.168.1.1/image?iname=VAR and VAR is variable from the user interface ModelApi { @POST("/image") suspend fun pushImageToModelFromAPI( @Body file: RequestBody, ) } i tried the above code but this doesn’t work >Solution : For query params you need to use @Query. Like this:… Read More how to POST parameters to server using retrofit2?

Optional parameter in retrofit method

I have 2 methods: @POST("/example") fun getSomething(@Body string: String) @POST("/example") fun getSomethingWithHeader(@Body string: String, @Header header: String) Sometimes I have to post with header sometimes without, it works but in my opinion it could be one method especially with kotlin default args. But something like: @POST("/example") fun getSomethingWithHeader(@Body string: String, @Header header: String = "")… Read More Optional parameter in retrofit method

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 39 path $.message

i am making login function in android using retrofit. I have created an endpoint for login validation, then I have tested it using Postman using raw (json) and it worked. But when I enter the endpoint into android using retrofit I get an error message like this: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT… Read More com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 39 path $.message

Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 retrofit2

I have problem with my project. It is simple connection with api application. I want to take information like this: { "docs": [ { "_id": "5cf5805fb53e011a64671582", "name": "The Fellowship Of The Ring" }, { "_id": "5cf58077b53e011a64671583", "name": "The Two Towers" }, { "_id": "5cf58080b53e011a64671584", "name": "The Return Of The King" } ], "total": 3, "limit":… Read More Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 retrofit2