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

    Create a hidden form field via the REST API

      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
          }