Endpoints for Documents

Prev Next

Interact with IDP documents through APIs from ProcessMaker scripts.

Base URL for Document Endpoints

Access the server via https://{processmaker-server}/api/1.0/connector-idp.

View Metadata of a Document

GET https://{processmaker-server}/api/1.0/connector-idp/get-file/{id}

See 200 status code response for cURL example and response example.

Path Parameters

Name

Type

Description

id*

String

Unique ID for the document to find in the information document section of the IDP server.

Following is an example of getting a document metadata using the file id.

cURL request:

curl --location --request GET "https://processmaker.com/api/1.0/connector-idp/get-file/d72c9a40-8ef1-4c16-94c8-038cd9b80089"

Example response:

The request was okay and the response body contains the representation requested.

{
  "data": {
    "type": "file",
    "attributes": {
      "createdAt": "2019-11-29T09:46:29.006+0000",
      "createdBy": "User",
      "documentType": "NONE",
      "modifiedAt": "2019-12-03T07:41:33.445+0000",
      "name": "Welcome to IDP.docx",
      "modifiedBy": null,
      "checkedOutBy": null,
      "id": "d72c9a40-8ef1-4c16-94c8-038cd9b80089",
      "content": 117350
    },
    "relations": {}
  },
  "status": "success",
  "message": null
}
  1. Create a Script to get the metadata of the IDP file using a file id.

  2. Add the Script Task to your process model.

  3. Reference the created script.

<?php
/*
 *  Welcome to ProcessMaker 4 Script Editor
 *  To access Environment Variables use getenv("ENV_VAR_NAME")
 *  To access Request Data use $data
 *  To access Configuration Data use $config
 *  To preview your script, click the Run button using the provided input and config data
 *  Return an array and it will be merged with the processes data
 *  Example API to retrieve user email by their ID $api->users()->getUserById(1)['email']
 *  API Documentation https://github.com/ProcessMaker/docker-executor-php/tree/master/docs/sdk
 */

$start = microtime(true);
$guzzleClient = new \$GuzzleHttp\Client(['base_uri'=> getenv('API_HOST'),'verify' => false]);
$guzzleOptions['headers']['Accept'] = 'application/json';
$guzzleOptions['headers']['Authorization'] = 'Bearer'.getenv('API_TOKEN');

$guzzleApi = '/api/1.0/connector-idp/get-file/be74e981-f82c-data-b906-669724f0c37f';
$result = json_decode($guzzleClient->request('GET', $guzzleApi, $guzzleOptions)->getBody(),true)['data'];

return $result;

Update Documents

PUT https://{processmaker-server}/api/1.0/connector-idp/update-file/{id}

See 200 status code response for cURL example and response example.

Path Parameters

Name

Type

Description

id*

String

Unique ID for the document to find in the information document section of the IDP server.

Request Body

Name

Type

Description

data

JSON String

Attributes specified as key-value pairs. Check the example response to see the JSON structure to send

Here is an example of updating a file using the file id., where the file attributes are being updated.

cURL request:

curl --location --request PUT "https://processmaker.com/api/1.0/connector-idp/update-file/d72c9a40-8ef1-4c16-94c8-038cd9b80089"

Example response:

The request was okay and the response body contains the representation requested. The response contains all attributes of the updated document.

{
  "data": {
    "type": "file",
    "attributes": {
      "createdAt": "2023-12-03T12:47:06.960+0000",
      "createdBy": "User",
      "documentType": "NONE",
      "modifiedAt": "2023-12-05T12:47:06.960+0000",
      "name": "Welcome back to IDP.docx",
      "modifiedBy": "User2",
      "checkedOutBy": "User",
      "id": "d72c9a40-8ef1-4c16-94c8-038cd9b80089",
      "content": 125398,
      "parentId": null
    }
  },
  "status": "success",
  "message": null
}
<?php
/*
 *  Welcome to ProcessMaker 4 Script Editor
 *  To access Environment Variables use getenv("ENV_VAR_NAME")
 *  To access Request Data use $data
 *  To access Configuration Data use $config
 *  To preview your script, click the Run button using the provided input and config data
 *  Return an array and it will be merged with the processes data
 *  Example API to retrieve user email by their ID $api->users()->getUserById(1)['email']
 *  API Documentation https://github.com/ProcessMaker/docker-executor-php/tree/master/docs/sdk
 */

$start = microtime(true);
$guzzleClient = new \$GuzzleHttp\Client(['base_uri'=> getenv('API_HOST'),'verify' => false]);
$guzzleOptions['headers']['Accept'] = 'application/json';
$guzzleOptions['headers']['Authorization'] = 'Bearer'.getenv('API_TOKEN');

$guzzleOptions['json'] = [
    "attributes" => [
        "fulltext" => "Hello World",
        "name" => "Finance Invoice",
        "documentType" => "Invoice"
    ]
];

$guzzleApi = '/api/1.0/connector-idp/get-file/be74e981-f82c-data-b906-669724f0c37f';
$result = json_decode($guzzleClient->request('GET', $guzzleApi, $guzzleOptions)->getBody(),true)['data'];

return $result;