-1

I need to send an array with Post Request using Retrofit. In Postman worked correctly like this enter image description here

But in Android, I can not send the correct request.Please, help me.

UPDATE

I try like this:

 @POST("/api/friends")
fun getContactsList(@Header("Authorization") token String,@Query("phones[]") phones : Array<String>) : Single<List<Friends>>
Mukhit
  • 152
  • 2
  • 10
  • Hello there option to send data using array can just confirm that what data your server side encoded so base on that we can construct from android and send to post request – Navin Jan 28 '19 at 10:43
  • The server side says that I should send an array and token in headers. And I tried several options for sending an array, but I get a empty list.In Postman worked correctly. – Mukhit Jan 28 '19 at 11:04
  • have you tried to send post request using RequestBody – Navin Jan 28 '19 at 11:13
  • https://johnsonsu.com/android-retrofit-posting-array/ please check might be usefull for you – Navin Jan 28 '19 at 11:16

1 Answers1

1

I think you can try this:

@POST("http://server/service")
Call<YourModel> postSomething(@Query("phones") List<String> array);

Generated url should look like this: http://server/service?phones=123&phones=345&phones=567&phones=789