how to execute a service correctly with @POST in java with retrofit2

52
January 13, 2019, at 01:00 AM

I'm using the retrofit2 library, the method I use is an @POST but I do not understand why it gives me an error, I currently send the data in an @Body however in postman I have it in the following way

so I execute it from java

 @POST(Constants.Retrofit.WORK_WITH_AS)
    Call<List<SuggestionsResponse>> setWorkWithAs(@Body WorkWithAs body);

I'm not sure if I'm doing it the right way, I need to be told what kind of note to make in order to post this data.

Answer 1

This will be similar to your api call :

@FormUrlEncoded
@POST("Pass url of your api")
Call<User //Data class from POJO> setWorkWithAs(//Provide Field you have given in Postman);

Call for you :

List<SuggestionsResponse> if this is your data class then

Call<List<SuggestionsResponse>> setWorkWithAs(@Field("name") String name, @Field("lastname") String lastname, @Field("document_type") Int document_type, @Field("document_num") Int document_num, @Field("email") String email, @Field("phone") Int phone, @Field("cellphone") Int cellphone, @Field("area") Int area, //Provide Multipart here);
READ ALSO
apk signed with a different certificate problem

apk signed with a different certificate problem

My original application was created in Android Studio and I have updated it by appybuilder

54
Retrieve preferences from intelliJ platform IDE

Retrieve preferences from intelliJ platform IDE

I am writing plugin for Android Studio in Java and currently need to determine user's android SDK locationAs far as I know, the location of SDK can be set by user in: Android Studio -> Preferences -> Appearance and Behavior -> System Settings -> Android...

53
Remove &ldquo;view more&rdquo; button in WhatsApp stickers?

Remove “view more” button in WhatsApp stickers?

There are some sticker packs for WhatsApp that don't show a "view more" button on their click menuThere is a line in a smali file which defines to which Play Store app the button should take

34
How to remove/block popup ads in webview Android?

How to remove/block popup ads in webview Android?

I have a problem with my webview Android appIt always show randomize ads from unknown sources

57