F
F
foonfyrick2021-03-04 16:10:12
Android
foonfyrick, 2021-03-04 16:10:12

Retrofit, what do these annotation options do?

1) @Field annotation which has value and encoded parameters, I can't figure out how it works. I can send pojo to the test site, pojo consists of 4 fields, body, id, title, userId, but using this annotation, I can send from 1 to 4 fields and the response from the server will be positive, why? How does encoded = true work? I set it to true and see no difference from the answer.

@FormUrlEncoded
    @POST("/posts")
    fun post(@Field("title",encoded = true) title:String):Call<ResponseBody>


2) In what situation should one use the @OPTION S annotation? It is written that it should contain the full url address to the end point, but for what? After all, the whole path can be written without this annotation. The same is written for @HEAD, @HTTP annotations.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-03-04
@foonfyrick

Why does the server respond to a request that, as I understand it, you consider incorrect, the question is for the creator of the server, here you will not be answered.
Encoded is needed to % encode data that cannot be part of the URI.
Apparently, there are situations when you want to go to URIs with different hosts / schemes through one retrofit service. If you don't need it, just don't use it. It will take - remember and zayuzayesh.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question