How to add array to okhttp body (POST)

前端 未结 1 435
一个人的身影
一个人的身影 2020-12-11 05:45

Now i`m adding array as string to body:

RequestBody body = new FormEncodingBuilder()
    .add(\"profiles\", \"[122, 125, 336]\")
    .build();
相关标签:
1条回答
  • 2020-12-11 06:36

    You are currently posting profiles as a string. You will want to mimic a POST for a checkbox form field for profiles

    RequestBody body = new FormEncodingBuilder()
        .add("profiles[0]", "122")
        .add("profiles[1]", "125")
        .add("profiles[2]", "336")
        .build();
    

    more info and good reading,

    • https://teamtreehouse.com/community/how-to-handle-multiple-checkboxes-values-in-a-form-using-php
    • Get $_POST from multiple checkboxes
    0 讨论(0)
提交回复
热议问题