Android (java) - Post (with Headers) With Retrofit 2.1.0
I need to integrate a RESTful API called SMMRY into my Android App. This API does automatic text summary of an URL or block of text that is sent to it. I am using Retrofit 2.1.0 as
Solution 1:
In my opinion both first and third options are correct.
Notice that in first case when you add only annotation @Headers it is added only for one call, but if you create Interceptor headers will be added in all calls witch use this OkHttpClient.
But I think your problem is in different place. I think you misunderstood SMMRY documentation. The "sm_api_input" is not query parameter.
Please try the following code:
@FormUrlEncoded@POST("/")
Call<SmmaryResponse> getSummaryText(@Query("SM_API_KEY") String apiKey,
@Field("sm_api_input") String bText,
@Query("SM_LENGTH") Integer length,
@Query("SM_WITH_BREAK") Boolean wBreak,
@Query("SM_QUOTE_AVOID") Boolean quote,
@Query("SM_KEYWORD_COUNT") Integer N);
Best regards, Marcin
Post a Comment for "Android (java) - Post (with Headers) With Retrofit 2.1.0"