Form API REST - Get form CAMUNDA 8

Good morning team,

When I make a request to the endpoint:
http:urlbase/v1/forms/{formId}?processDefinitionKey={processDefinitionKey}&version={formVersion}
I receive a response like the example below:

{
	"id": "identificationDocumentID",
	"processDefinitionKey": "2251799815198234",
	"schema": "{\n  \"executionPlatform\": \"Camunda Cloud\",\n  \"executionPlatformVersion\": \"8.4.0\",\n  \"exporter\": {\n    \"name\": \"Camunda Web Modeler\",\n    \"version\": \"2466e06\"\n  },\n  \"schemaVersion\": 14,\n  \"id\": \"identificationDocumentID\",\n  \"components\": [\n    {\n      \"text\": \"# Insira um número de documento válido\\nErro na validação do documento de identificação com número  {{iNumDocIdentificacao}}\\n\",\n      \"label\": \"Text view\",\n      \"type\": \"text\",\n      \"layout\": {\n        \"row\": \"Row_07t79a1\",\n        \"columns\": null\n      },\n      \"id\": \"Field_1038pg9\",\n      \"conditional\": {\n        \"hide\": \"=iNumDocIdentificacao=null\"\n      }\n    },\n    {\n      \"text\": \"# Erro de comunicação\\nOcorreu um erro ao comunicar-se com o orgão competente a validação do documento de identificação\",\n      \"label\": \"Text view\",\n      \"type\": \"text\",\n      \"layout\": {\n        \"row\": \"Row_0vlyuli\",\n        \"columns\": null\n      },\n      \"id\": \"Field_0j4u7da\",\n      \"conditional\": {\n        \"hide\": \"=iNumDocIdentificacaoErrorCheck=null\"\n      }\n    },\n    {\n      \"label\": \"Tipo de Entidade\",\n      \"type\": \"select\",\n      \"layout\": {\n        \"row\": \"Row_0kbuskr\",\n        \"columns\": null\n      },\n      \"id\": \"Field_1ap3iq2\",\n      \"key\": \"tipoEntidadeID\",\n      \"valuesKey\": \"iTipoEntidadeList\"\n    },\n    {\n      \"values\": [\n        {\n          \"label\": \"Bilhete de Identidade\",\n          \"value\": \"BI\"\n        },\n        {\n          \"label\": \"Passaporte\",\n          \"value\": \"PA\"\n        },\n        {\n          \"label\": \"Autorização de Residência \",\n          \"value\": \"CRE\"\n        },\n        {\n          \"label\": \"Cédula\",\n          \"value\": \"CD\"\n        }\n      ],\n      \"label\": \"Tipo de Documento\",\n      \"type\": \"select\",\n      \"layout\": {\n        \"row\": \"Row_17j1hd3\",\n        \"columns\": null\n      },\n      \"id\": \"Field_0x2auug\",\n      \"key\": \"tipoDocumentoID\",\n      \"validate\": {\n        \"required\": true\n      }\n    },\n    {\n      \"label\": \"Nº do Documento\",\n      \"type\": \"textfield\",\n      \"layout\": {\n        \"row\": \"Row_17j1hd3\",\n        \"columns\": null\n      },\n      \"id\": \"Field_0zyyhqn\",\n      \"key\": \"numeroDocumentoID\",\n      \"validate\": {\n        \"required\": true\n      }\n    }\n  ],\n  \"type\": \"default\"\n}",
	"version": 2,
	"tenantId": "<default>",
	"isDeleted": false
}

It is possible to format the request so that it is already organized without the “\n” in the expression, as in the example below:

{
  "id": "identificationDocumentID",
  "processDefinitionKey": "2251799815198234",
  "schema": {
    "executionPlatform": "Camunda Cloud",
    "executionPlatformVersion": "8.4.0",
    "exporter": {
      "name": "Camunda Web Modeler",
      "version": "2466e06"
    },
    "schemaVersion": 14,
    "id": "identificationDocumentID",
    "components": [
      {
        "text": "# Insira um número de documento válido\nErro na validação do documento de identificação com número  {{iNumDocIdentificacao}}\n",
        "label": "Text view",
        "type": "text",
        "layout": {
          "row": "Row_07t79a1",
          "columns": null
        },
        "id": "Field_1038pg9",
        "conditional": {
          "hide": "=iNumDocIdentificacao=null"
        }
      },
      {
        "text": "# Erro de comunicação\nOcorreu um erro ao comunicar-se com o orgão competente a validação do documento de identificação",
        "label": "Text view",
        "type": "text",
        "layout": {
          "row": "Row_0vlyuli",
          "columns": null
        },
        "id": "Field_0j4u7da",
        "conditional": {
          "hide": "=iNumDocIdentificacaoErrorCheck=null"
        }
      },
      {
        "label": "Tipo de Entidade",
        "type": "select",
        "layout": {
          "row": "Row_0kbuskr",
          "columns": null
        },
        "id": "Field_1ap3iq2",
        "key": "tipoEntidadeID",
        "valuesKey": "iTipoEntidadeList"
      },
      {
        "values": [
          {
            "label": "Bilhete de Identidade",
            "value": "BI"
          },
          {
            "label": "Passaporte",
            "value": "PA"
          },
          {
            "label": "Autorização de Residência",
            "value": "CRE"
          },
          {
            "label": "Cédula",
            "value": "CD"
          }
        ],
        "label": "Tipo de Documento",
        "type": "select",
        "layout": {
          "row": "Row_17j1hd3",
          "columns": null
        },
        "id": "Field_0x2auug",
        "key": "tipoDocumentoID",
        "validate": {
          "required": true
        }
      },
      {
        "label": "Nº do Documento",
        "type": "textfield",
        "layout": {
          "row": "Row_17j1hd3",
          "columns": null
        },
        "id": "Field_0zyyhqn",
        "key": "numeroDocumentoID",
        "validate": {
          "required": true
        }
      }
    ],
    "type": "default"
  },
  "version": 2,
  "tenantId": "<default>",
  "isDeleted": false
}

Hi @Domingos_Dias - you need to parse the value of the schema property. For instance, if you are using Javascript, you can do something like: const formSchema = JSON.parse(response.body.schema). For now there is no other way, and I’ve personally found this pattern to be quite common when working with APIs that return documents (for instance, one API I use regularly returns a PDF as a base64 encoded string that I need to parse). I’ll absolutely take your feedback to the product team, though, so they can consider possible changes during development and planning!

1 Like