5 Replies Latest reply on Mar 16, 2020 10:17 PM by Lou Patrick

    API - Change value of form field

    andrepazleal

      I have a specific need using the end point I need modify the type and value of a specific field in the form:

       

      /api/REST/1.0/assets/form/id

      {

          "id":"",

          "name":"api test",

          "elements":[

              {

                  "type":"FormField",

                  "id":"26197",

              "name": "Sales Org",

              "displayType": "text",

                  "defaultValue": "TSL",

                  "validations":[

                  ]

              }

          ],

          "emailAddressFormFieldId":"26192",

          "processingSteps":[

          ],

          "processingType":"externalWebsite"

      }

       

      Ok I've managed to change the field type and the value but when I request this all the others fields dissapear leaving only the current one, what I'm making wrong?

        • 1. Re: API - Change value of form field
          Lou Patrick

          If using a PUT request, you need to include all the fields in the request. To update one field, without needing to include the other fields, you could use the PATCH endpoint - PATCH /api/REST/2.0/assets/form/{id}.

           

          Note, if both 2.0 and 1.0 are available, which they are for forms, the 2.0 endpoints should be used, as there are certain features that are only available on 2.0.

          • 2. Re: API - Change value of form field
            andrepazleal

            Sorry for the delay on the answer. Thanks Lou.

             

            By the way that modification using patch it worked, if I need to change multiples forms the same field and value, can that be done thru the same PATCH request? Can you share one example?

            • 3. Re: API - Change value of form field
              andrepazleal

              Lou regarding your answer, I've added the patch:

              {

                  "id":"4165",

                  "name":"andre tests",

                  "elements":[

                      {

                          "type":"FormField",

                          "id":"45551",

                      "name": "Sale",

                      "displayType": "text",

                      "defaultValue": "TSL"

                      }

                  ]

              }

               

              And it's returning in postman validation error (400):

              [     {         "type": "ObjectValidationError",         "container": {             "type": "ObjectKey",             "objectId": "4165",             "objectType": "Form"         },         "property": "HTML",         "requirement": {             "type": "NotNullRequirement"         },         "value": "4165"     } ]

              • 4. Re: API - Change value of form field
                Lou Patrick

                As the response message indicates, the HTML property, "htmlName" is required. For forms "htmlName" is in the same category as "id" and "name", it must always be included with a PUT or PATCH request.

                • 5. Re: API - Change value of form field
                  Lou Patrick

                  Unfortunately there is not a way to update more than one form per PATCH request. Only one form can be updated per request.