APIs for resources

APIs for resources

Below the APIs for resources are listed. APIs are introduced here.

List resources in folder

Returns a list of resources of a specific type in a folder.

GET <NG2_URL>/restapi/v1/resourceFolder/<type>/**?start=5&length=100

Replace ** with the path and name of the resource folder.

Input:

  • <type>: The resource type, for instance “template”.

  • start: Optional index of the first resource to return (default is 0).

  • length: Optional maximum number of resources to return (default is all).

JSON example output:

{ "total": 1, "resources": [ { "metaData": { "SIZE": 127749, "LAST_MODIFIED": 1743172227094, "PROVIDER": "FILE", "READ_ONLY": false, "ORIGINAL_PATH": "C:\\ProgramData\\InterFormNG2\\resources\\home\\template\\ASTRO\\PREADVICE_PDFUA.ift", "LAST_USED": 1746019879810 }, "name": "PREADVICE_PDFUA.ift", "path": "/ASTRO/PREADVICE_PDFUA.ift", "directory": false, "fileType": "FILE" } ]
}


Create a resource folder

Creates a folder in the library of a specific resource type.

POST <NG2_URL>/restapi/v1/resourceFolder/<type>/**

Replace ** with the path of the parent folder.

Input:

  • <type>: The resource type, for instance “template”.

  • The body of the request must be a JSON object with the name of the folder to create

Example JSON input:

{     "folderName": "created from api"
}

Typical HTTP error codes:

  • 400: Folder name missing from request body.

  • 422: Parent resource if not a folder.

  • 404: The parent folder does not exist.


Read resource

Returns the binary content of a resource.

GET <NG2_URL>/restapi/v1/resource/<type>/**

Replace ** with the path and name of the resource.

Input:

  • <type>: The resource type, for instance “template”.

Typical HTTP error codes:

  • 404: The resource does not exist.


Upload resource

Uploads a file and either creates a new resource or replaces the content of an existing resource.
Note that for versioned resources where the approval process is enabled, existing resources will only be checked out. /restapi/v1/resourceApproval/ can be used afterwards to create an approval task.

POST <NG2_URL>/restapi/v1/resource/<type>/**?checkoutOnly=true&versionDescription="change description"

Replace ** with the destination path of the resource.

Input:

  • <type>: The resource type, for instance “template”.

  • checkoutOnly: Optional, only relevant for versioned resources. Set this to true if the existing resource should only be checked out. If this is false, a new version is immediately published.

  • versionDescription: Optional, only relevant when checkoutOnly=true. The description of the changes in this version.

JSON example output (output if the resource was checked out):

{ "checkedOut": true
}

Typical HTTP error codes:

  • 409: The resource is locked due to a previous change pending approval.


Delete resource

Deletes a resource.

DELETE <NG2_URL>/restapi/v1/resource/<type>/**

Replace ** with the path and name of the resource.

Input:

  • <type>: The resource type, for instance “template”.

Typical HTTP error codes:

  • 409: The resource is locked due to a previous change pending approval.


Move resource

Moves or renames an existing resource.

PATCH <NG2_URL>/restapi/v1/resource/<type>/**

Replace ** with the path and name of the resource to move/rename.

Input:

  • <type>: The resource type, for instance “template”.

  • The body of the request must be a JSON object with the destination path and name.

Example JSON input:

{     "destinationPath": "ASTRO/moveme.ift"
}

Typical HTTP error codes:

  • 400: Destination path missing from request body.

  • 404: The resource does not exist.

  • 400: Missing destination path.


Create approval task

Creates an approval task for a resource or a set of dependent resources. For instance when requesting approval for a template, it can make sense to also include any modified translations or images that are used by the template.

POST <NG2_URL>/restapi/v1/resourceApproval/<type>/**

Replace ** with the path and name of the primary resource to request approval for.

Input:

  • <type>: The resource type, for instance “template”.

  • The body of the request must be a JSON object with additional information about the approval request.

    • Description: The description of the changes.

    • approvalWorkflowId: The ID of the workflow that should be used for the approval process.

    • major: True if the change should result in a new major version.

    • additionalResources: Type and path of all modified resources that are related to the primary resource.

Example JSON input:

{     "description": "Changed header design",     "approvalWorkflowId": "Final",     "major": false,     "additionalResources": {         "resource" : [             {                 "resourceType": "translation",                 "path": "std/translations.properties"             }         ]     }
}

Typical HTTP error codes:

  • 409: The resource is locked due to a previous change pending approval.

  • 422: Versioning-related error, typically that the resource is checked out by another user or the approval workflow ID is incorrect.

    • Related Articles

    • APIs

      Introduction The following describes the InterFormNG2 APIs. <NG2_URL> is used to denote the base URL of InterFormNG2, by default https://localhost:8086 Swagger documentation Swagger documentation for external API, authorization and webservice input ...
    • List resources

      The advanced, utilities workflow component, List resources can be used in order to generate a list of all resources in a specific directory. The list is generated as an XML file and is output into the payload of the current workflow. Please notice, ...
    • Save in resources

      When using systems like IBM i or in the cloud, then sometimes the client needs an easy way to save an XML for later viewing while creating and testing workflows. The IBM i green screen or remote desktop connection to cloud servers etc. is not an ...
    • Versioning of resources

      One optional feature in InterFormNG2 is versioning of resources. The versioning features makes it possible to maintain a version history on resources in the library. Versioning of resources is a way to keep track of changes to resources and this can ...
    • APIs for printers

      Below you see a list of the APIs for printers in InterFormNG2. APIs are introduced here. List system printer names This returns a list with the names of all printers that are installed on the O/S on the InterFormNG2 host machine. GET ...