PHP Quick Start

VisualVault REST API requests using PHP

PHP FormTemplates

Request a list of Form Templates

// REQUEST
$AccessToken = '{AccessToken}';
$endpoint = 'https://demo.visualvault.com/api/v1/{customerAlias}/{databaseAlias}/formtemplates/';
$ch = curl_init();
curl_setopt_array($ch, array(
  CURLOPT_HTTPGET => true,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer ' . $AccessToken),
  CURLOPT_URL => $endpoint
  ));
curl_exec($ch);
curl_close($ch);

// RESPONSE
{
  "meta": {
    "status": 200,
    "statusMsg": "OK",
    "method": "GET",
    "href": "https://demo.visualvault.com/api/v1/{customerAlias}/{databaseAlias}/formtemplates/"
  },
  "data": [
    {
      "href": "~/formtemplates/dc7e2924-7518-e211-92ad-000c29753f96",
      "dataType": "FormTemplate",
      "id": "dc7e2924-7518-e211-92ad-000c29753f96",
      "name": "Purchase Requisition - Template",
      "modifyDate": "2014-11-04T12:22:16.377",
      "modifyById": "{userId}",
      "modifyBy": "{userName}",
      "createDate": "2012-10-17T09:10:18.277",
      "createById": "{userId}",
      "createBy": "{userName}",
      "description": "Purchase Requisition",
      "revisionId": "80183524-7518-e211-92ad-000c29753f96",
      "revision": 1,
      "templateRevision": "1",
      "status": 1
    },
    {
      "href": "~/formtemplates/1b4b682e-b4fb-e211-9c69-0013210b5170",
      "dataType": "FormTemplate",
      "id": "1b4b682e-b4fb-e211-9c69-0013210b5170",
      "name": "Expense Report Line Item",
      "modifyDate": "2013-08-02T13:44:17.12",
      "modifyById": "{userId}",
      "modifyBy": "{userName}",
      "createDate": "2013-08-02T13:43:27.583",
      "createById": "{userId}",
      "createBy": "{userName}",
      "description": "Expense Report Line Item",
      "revisionId": "f5732e2e-b4fb-e211-abed-000c291aac29",
      "revision": 1,
      "templateRevision": "1",
      "status": 1
    },
  ]
}

Requests all Form Templates

Request Form Fields of a Form Template

// REQUEST
$AccessToken = '{AccessToken}';
$endpoint = 'https://demo.visualvault.com/api/v1/{customerAlias}/{databaseAlias}/formtemplates/';
$id = '{formTemplateId}';
$ch = curl_init();
curl_setopt_array($ch, array(
  CURLOPT_HTTPGET => true,
  CURLOPT_HTTPHEADER => array(
  	'Content-Type: application/json',
    'Authorization: Bearer ' . $AccessToken),
  CURLOPT_URL => $endpoint . $id . '/fields'
  ));
curl_exec($ch);
curl_close($ch);

// RESPONSE
{
  "meta": {
    "status": 200,
    "statusMsg": "OK",
    "method": "GET",
    "href": "https://demo.visualvault.com/api/v1/{customerAlias}/{databaseAlias}/formtemplates/1b4b682e-b4fb-e211-9c69-0013210b5170/fields"
  },
  "data": {
    "fields": {
      "line item date": "Line Item Date",
      "place": "Place",
      "amount": "Amount",
      "explanation": "Explanation",
      "expense type": "Expense Type",
      "revisionid": "DhID",
      "instancename": "DhDocID",
      "modifydate": "VVModifyDate",
      "modifyby": "VVModifyBy",
      "modifybyid": "VVModifyByUsID",
      "createdate": "VVCreateDate",
      "createby": "VVCreateBy",
      "createbyid": "VVCreateByUsID"
    },
    "baseFields": [
      "RevisionId",
      "InstanceName",
      "ModifyDate",
      "ModifyById",
      "ModifyBy",
      "CreateDate",
      "CreateById",
      "CreateBy"
    ]
  }
}

Requests Fields of a Form Templates by id

Fill out Form Fields of a Form Template (creating a form instance)

// REQUEST
$AccessToken = '{AccessToken}';
$baseUrl = 'https://demo.visualvault.com/api/v1/{customerAlias}/{databaseAlias}/formtemplates';
$formId = '{formId}';
$request = $baseUrl . $formId . '/forms';
$fields = [
      'line item date' => 'this is the date',
      'place' => 'Oakland',
      'amount' => 'one dollar',
      'explanation' => 'hungry',
      'expense type' => 'hunger'
	];
$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => array(
		'Authorization: Bearer ' . $AccessToken),
    CURLOPT_POSTFIELDS => http_build_query($fields),
    CURLOPT_URL => $request
    ));
curl_exec($ch);
curl_close($ch);

// RESPONSE
{
  "meta": {
    "status": 201,
    "statusMsg": "Created",
    "method": "POST",
    "href": "https://demo.visualvault.com/api/v1/{customerAlias}/{databaseAlias}/formtemplates/1b4b682e-b4fb-e211-9c69-0013210b5170/forms"
  },
  "data": {
    "href": "~/formtemplates/1b4b682e-b4fb-e211-9c69-0013210b5170/forms/50876674-2c7c-e511-80d0-0050568d3d8b",
    "dataType": "FormInstance",
    "revisionId": "50876674-2c7c-e511-80d0-0050568d3d8b",
    "instanceName": "ERLI-000009",
    "modifyDate": "2015-10-26T14:56:48.97",
    "modifyById": "{userId}",
    "modifyBy": "",
    "createDate": "2015-10-26T14:56:48.97",
    "createById": "{userId}",
    "createBy": "{userName}"
  }
}

Fills out form fields of a form template and creates an instance of a form. These scripts will post fields as multipart/form-data by default. Use the http_build_query() as noted above to post fields with the header of your choice (in our case application/json). To post fields as multipart/form-data simply remove the http_build_query() and just submit the $fields array. Notice we used the first endpoint to get a form template. Next we used the second endpoint to request the fields of that template. Now here we are filling in those fields and creating an instance of the form template.