HomeGuidesRecipesAPI
HomeGuidesAPILog In

generation

The generate endpoint allows particular forms to be generated (often referred to as Submitted) as if they were run manually by a user in Produce. Usually some sort of data structure such as XML, JSON, CSV, named value pairs etc. are passed as part of the request to populate answers in the form.

The request to the generate end point require a id that references a particular Infiniti Form and behave according to how it is configured to behave upon submission in Design.

For example a generate request could:

  • Contain Data representing an end to end submission of a form. Often results in binary document(s), that can be requested by the API or pushed to another system via an Action configured as part of the form Design.
  • Contain data sufficient enough to submit the first state of a workflow so that a transition can be run and a pending workflow task be created and assigned to a user or group and appropriate notifications sent. Often forms will be configured so that the first or "start" state is a 'SystemState' that is completed using the data in the request and assigned to a specified or calculated user.

The generate method processes Asynchronously, meaning that the request is accepted and processed in the background, without making the requester wait for the process to finish. Thus if the requester wishes to receive binary documents Produced by the call they must poll the operations method to check the status of the generation, once it is successful generatedOutput method can be called to request Generated binaries.

📘

Prerequisite

Forms must be configured and published in Infiniti before they can be requested via the API

📘

Samples

See Sample code above for downloads, containing samples of the above

  • https://server/produce/api/v1/client/generate/:formGuid

Generate - Options

All the generation variations take an optional options object. Available properties are:

  • version, used with projects published with the "Match project version when loading in progress forms". This project version will be the one generated.

  • generationDateTime, used with projects published with the "Match project version when loading in progress forms". The project version modified before or on this date will be the one generated. If both version and generationDateTime properties are supplied, version will be used.

  • log, generations are logged by default but to reduce server and DB load this value can be set to false.

Example of the request body for generating a form with options:

{
  "options": {
    "version": "4.3",
    "generationDateTime": "2017-07-04T00:59:28.238Z",
    "log": true
  }
}

Generate - XML, JSON or CSV Datasources

To provide data to the project supply them in an array of data objects.

  • dataServiceGuid, optional. When this value is not supplied Infiniti will look for the first data source in the project that matches the schema and uses that as the GUID. This can be expensive so it is recommended to supply the value if it is known.

  • value, JSON/XML encoded string or CSV containing the contents of the data file.

{
   "data":[
      {
         "dataServiceGuid":"4cdc9148-5496-4d38-ad97-739478f7fb",
         "value":"<Document><Row><field_01>John</field_01><field_02>Doe</field_02><field_03>True</field_03><field_04>18</field_04><field_05>Tester</field_05></Row><Row><field_01>Janie</field_01><field_02>Doe</field_02><field_03>False</field_03><field_04>20</field_04><field_05>Developer</field_05></Row></Document>"
      }
   ]
}
<Document>
   <Row>
      <field_01>John</field_01>
      <field_02>Doe</field_02>
      <field_03>True</field_03>
      <field_04>18</field_04>
      <field_05>Tester</field_05>
   </Row>
   <Row>
      <field_01>Janie</field_01>
      <field_02>Doe</field_02>
      <field_03>False</field_03>
      <field_04>20</field_04>
      <field_05>Developer</field_05>
   </Row>
</Document>
{
   "data":[
      {
         "dataServiceGuid":"a9e97e5b-58d1-48da-9853-d9714626f275",
         "value":"\"Data\": [{\r\n      \"field_01\": \"John\",\r\n      \"field_02\": \"Doe\",\r\n      \"field_03\": \"True\",\r\n      \"field_04\": \"18\",\r\n      \"field_05\": \"Tester\"\r\n    },\r\n    {\r\n      \"field_01\": \"Janie\",\r\n      \"field_02\": \"Doe\",\r\n      \"field_03\": \"False\",\r\n      \"field_04\": \"20\",\r\n      \"field_05\": \"Developer\"\r\n    }\r\n  ]\r\n}"
      }
   ]
}
{
  "Data": [
    {
      "field_01": "John",
      "field_02": "Doe",
      "field_03": "True",
      "field_04": "18",
      "field_05": "Tester"
    },
    {
      "field_01": "Janie",
      "field_02": "Doe",
      "field_03": "False",
      "field_04": "20",
      "field_05": "Developer"
    }
  ]
}
{
   "data":[
      {
         "dataServiceGuid":"49626b76-2827-4576-8b65-4c6ef1e2457e",
         "value":"SN,American Samoa,Samoa américaine\r\nAT,Austria,Autriche"
      }
   ]
}
AS,American Samoa,Samoa américaine
AT,Austria,Autriche

Generate - Answer File

To generate the form with a pre-prepared answer file use the answerFile property. Answerfiles must be sourced by external code.

Example of the request body for generating a form with a pre-prepared answer file:

{
  "answerFile": "<AnswerFile><HeaderInfo><TemplateInfo TemplateGroupId=\"597ec154-d49c-421b-9232-a385782daae6\" RunId=\"27cfb19b-e751-40f2-aa03-0376becaafe6\" FirstLaunchTimeUtc=\"2018-11-05T23:07:20.6258204Z\" /></HeaderInfo><ProvidedData><Data Id=\"00000000-0000-0000-0000-000000000000\"><![CDATA[<sampleData><username>admin</username><firstName>sampleFirst</firstName><surname>sampleSurname</surname></sampleData>]]></Data></ProvidedData></AnswerFile>"
}
<AnswerFile>
   <HeaderInfo>
      <TemplateInfo TemplateGroupId="597ec154-d49c-421b-9232-a385782daae6" RunId="27cfb19b-e751-40f2-aa03-0376becaafe6" FirstLaunchTimeUtc="2018-11-05T23:07:20.6258204Z" />
   </HeaderInfo>
   <ProvidedData>
      <Data Id="00000000-0000-0000-0000-000000000000"><![CDATA[<sampleData><username>admin</username><firstName>sampleFirst</firstName><surname>sampleSurname</surname></sampleData>]]></Data>
   </ProvidedData>
</AnswerFile>

Generate - AnswerLabels (Key/Value Pairs)

For a lighter weight project, independent way of supplying values using the labels dictionary. Each property represents an answer file label name and its value. These values are turned into an answer file and applied to the form.

Example of the request body for generating a form with labels: key/values:

{
   "values":{
      "Answer1":"myValue1",
      "Answer2":"myValue2",
      "Answer3":"myValue3",
      "Answer4":"myValue4",
      "Answer5":"myValue5",
      "Answer6":"myValue6",
      "Answer7":"myValue7"
   }
}

Delayed Generate

To schedule a generation for a later time supply details for the schedule property.

  • name, a description of this generation that will appear in Manage

  • startDateTime, a date to begin this generation after.

Example of the request body for scheduling generation of a form:

{
   "schedule":{
      "startDateTime":"2017-07-04T00:59:28.239Z",
      "name":"This is a test for Infiniti REST API Delayed Generate"
   }
}

Generate - Workflow

To generate a form and at the same time define who will receive a workflow state after a transition is done, this can either be assigned to a specific user or a specific group.

  • comment, comment for the assignment to the next user.

  • sendToUserGuid, The user guid to assign the next state to.

  • sendToUserName, The username guid to assign the next state to.

  • sendToGroupGuid, The group guid to assign the next state to.

  • sendToGroupName, The group name to assign the next state to.

  • nextState, name of the next state the workflow will transition into.

Example of the request body for assigning the next state of a workflow to a specific user using either user guid or username:

{
   "workflow":{
      "comment":"This is a test for Infiniti REST API Generate with Workflow",
      "sendToUserName":"admin"
   }
}
{
   "workflow":{
      "comment":"This is a test for Infiniti REST API Generate with Workflow",
      "sendToUserGuid":"d1f7be9e-2fea-4fb9-9dcd-855b6ba2a7a0"
   }
}
{
   "workflow":{
      "comment":"This is a test for Infiniti REST API Generate with Workflow",
      "sendToGroupName":"Tester"
   }
}
{
   "workflow":{
      "comment":"This is a test for Infiniti REST API Generate with Workflow",
      "sendToGroupGuid":"7fd8c5bc-51af-4442-9add-583315b649fd"
   }
}