4 Replies Latest reply on Nov 30, 2017 11:55 AM by Sanford Whiteman

    Create a hidden form field via the REST API

    Gold Gold

      Following this tread I'm also trying to update forms with hidden field but I can't figure how to do it.

       

      Can you guys please show POST example on how to do it.

       

      We have a field which is called "formCategory"

       

      POST Example

      payload = {'id': 1638, 'addFormFieldSetRequest': {

        "fieldId": "formCategory",

        "fieldType": "hidden"

      }}

      r = requests.post('https://...mktorest.com/rest/asset/v1/form/1638/fields.json?access_token=...', params=payload)

       

      Response:

      {'success': False, 'errors': [{'message': 'fieldId cannot be null.', 'code': '701'}], 'requestId': None, 'warnings': []}

        • Re: Create a hidden form field via the REST API
          Sanford Whiteman

          Doesn't look like you're understanding the REST docs correctly (and they are a little bit SOAP-like in this regard).

           

          addFormFieldSetRequest is the internal name of the property bag. That string never appears in the payload. The payload has a top-level JSON object like

           

          {
            "blankFields": 0,
            "defaultValue": "string",
            "fieldId": "string",
            "fieldType": "string",
            "fieldWidth": 0,
            "formPrefill": true,
            "hintText": "string",
            "initiallyChecked": true,
            "instructions": "string",
            "label": "string",
            "labelToRight": true,
            "labelWidth": 0,
            "maskInput": "string",
            "maxLength": 0,
            "maxValue": 0,
            "minValue": 0,
            "multiSelect": true,
            "required": true,
            "validationMessage": "string",
            "values": "string",
            "visibleLines": 0
          }
          

           

           

           

            • Re: Create a hidden form field via the REST API
              Gold Gold

              When we send "fieldType": "email" the call is success and we can see in marketo that thr form updated correctly

              When send "fieldType": "hidden" the response is {'code': '611', 'message': 'System error'}

               

               

              Payload with the success call

              url_form_id = ".../rest/asset/v1/form/1638/fields.json"

              payload = {'access_token': token,   "blankFields": 0,

                "defaultValue": "Demo",

                "fieldId": "formCategory",

                "fieldType": "email",

                "fieldWidth": 150,

                "formPrefill": "true",

                "hintText": "",

                "initiallyChecked": "true",

                "instructions": "",

                "label": "form_category",

                "labelToRight": "true",

                "labelWidth": 100,

                "maskInput": "",

                "maxLength": 255,

                "maxValue": 0,

                "minValue": 0,

                "multiSelect": "true",

                "required": "false",

                "validationMessage": "",

                "values": "",

                "visibleLines": 0}

               

              r = requests.post(url_form_id, params=payload)

              pp.pprint(r.json())

               

               

              Exact Payload but now fieldType = hidden

              url_form_id = ".../rest/asset/v1/form/1638/fields.json"

              payload = {'access_token': token,   "blankFields": 0,

                "defaultValue": "Demo",

                "fieldId": "formCategory",

                "fieldType": "hidden",

                "fieldWidth": 150,

                "formPrefill": "true",

                "hintText": "",

                "initiallyChecked": "true",

                "instructions": "",

                "label": "form_category",

                "labelToRight": "true",

                "labelWidth": 100,

                "maskInput": "",

                "maxLength": 255,

                "maxValue": 0,

                "minValue": 0,

                "multiSelect": "true",

                "required": "false",

                "validationMessage": "",

                "values": "",

                "visibleLines": 0}

               

              r = requests.post(url_form_id, params=payload)

              pp.pprint(r.json())