0

How to do this post request in retrofit2?

curl --location --request POST "http://localhost/projectjcms/api/search-result" \
  --header "accessToken: eyJ0eOiJK 3ZN_ud117ZPLSQMC0ry-tGUfOmLvgsLqRQIA" \
  --header "lang: 1" \
  --header "Content-Type: text/plain" \
  --form "property_type[0]=1" \
  --form "property_type[1]=2" \
  --form "bedroom_type[0]=1" \
  --form "bedroom_type[1]=5" \
  --form "bedroom_type[2]=3"

RequestBody unitDetailsRequestBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("property_id[0]", "3") //.addFormDataPart("property_id[1]", "2") .build();

   // @FormUrlEncoded
    @POST("api/search-result")
    Call<Frame> getSearchResult(@Header("accessToken") String accessToken,
                                @Header("lang") int language,
                                @Header("Content-Type") String contentType,
                                @Body String body);
Midhilaj M
  • 11
  • 2

1 Answers1

0

You can refer below code to call API.

@FormUrlEncoded
@POST("api/search-result")
Call<Frame>  getSearchResult(@Field("property_type[]") String[] propertyType,
                     @Field("bedroom_type[]") String[] bedroomType);
DHAVAL A.
  • 2,251
  • 2
  • 12
  • 27