android studio retrofit2 post code example

Example 1: android retrofit post json example

Follow these steps:

1.) Firstly create modal class (MyRequestClass) for your Post request from http://www.jsonschema2pojo.org/

2.) Also create modal (MyResponseClass) for your server response from same site.

3.) Set values you want to send to your server by creating object of MyRequestClass.

4.) Then hit api using this method in your interface:

@POST("/provider/filter")
Call<MyResponseClass> sendDataToServer(@Body MyRequestClass myModal);

Example 2: android retrofit2 example

compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'

Tags:

Misc Example