How to post array in retrofit android

前端 未结 7 1812
旧巷少年郎
旧巷少年郎 2020-11-27 19:55

How can I post following parameter in retrofit through post method ?

 \"params\":{\"body\": {
    \"learning_objective_uuids\": [
      \"ED4FE2BB2008FDA9C81         


        
7条回答
  •  孤街浪徒
    2020-11-27 20:24

    As of today, running the Retrofit implementation 'com.squareup.retrofit2:retrofit:2.1.0'

    This works perfectly...

    @FormUrlEncoded
    @POST("index.php?action=item")
    Call updateManyItem(@Header("Authorization") String auth_token, @Field("items[]") List items, @Field("method") String method);
    

    You can disregard the @Header and @Field("method") .... the main piece is @Field("items[]") List items

    This is what allows you to send the items. On the API side I am simply looking for an array of integers and this works perfectly.

提交回复
热议问题