How to submit checkbox values through the REST API v2 (what is the correct format) [RESOLVED]

Hello!

I’m currently submitting my form through the Gravity Forms REST API v2, and I’m submitting it as formData (uploading files).

So far all my values, including the file upload are working correctly except the checkbox field.

Does anyone know the correct format for checkbox values being submitted through the rest api? (and would this also apply to multiple selects)

Example data being posted: input_9 is the checkbox input

input_2: test
input_3: blah@gmail.com
input_4: adsf
input_6: First Choice
input_8: First Choice
input_9: First Choice,Second Choice

All other fields submit correctly (not seen is the file input, that also submits correctly)

I’ve also tried the following format:

input_2:test
input_3:blah@gmail.com
input_4:asdfasdf
input_6:First Choice
input_8:Second Choice
input_9[0]:Third Choice
input_9[1]:Second Choice

I saw in version 1 that a checkbox array needed to be sent as input_Number_index

so in this case it would be: input_9_1 etc

my js is:

for ( var key in obj ) {

       if(Array.isArray(obj[key])){

               let myArray = obj[key],
                      inputKey = key;

                                myArray.forEach(function (value, i) {

                                    // console.log(i, value);

                                    let number = i+1;

                                    form_data.append(

                                        inputKey+'_'+number,

                                        value

                                    );

                                });

                            } else {

                                form_data.append(key, obj[key]);

                            }

                        }

Is this working for you now, or do you still need assistance?

@chrishajer sorry for the later reply. Working great now!

1 Like
© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.