SAP Signavio Process Manager API client library

To use this feature you need an EnterprisePlus or API license and an active integration with SAP Signavio Process Manager. For the integration, read more in section Glossarintegration.

The SPM API client library simplifies HTTP requests to the SAP Signavio Process Manager (SPM) API in JavaScript tasks. It offers JavaScript methods to send HTTP GET, POST, PUT and DELETE requests. The library automatically authenticates requests using the account configured for the SAP Signavio Process Manager or Dictionary integration. All retrievable information is limited to what this account is allowed to access.

Import the library spm-client within a JavaScript task to use the SPM client.

const spmClient = require('spm-client')

The client offers four methods:

  • get('/path/to/endpoint', { key: 'value' })
  • post('/path/to/endpoint', { key: 'value' })
  • put('/path/to/endpoint', { key: 'value' })
  • delete('/path/to/endpoint', { key: 'value' })

Two parameters can be passed with the endpoint:

  • The mandatory API path that you want to call.
  • An optional object with request parameters. See the request library documentation for more information about all possible request parameters.

The response is a Promise providing the result of the request. In case of a successful request the response body is provided to the then function. In case of an error an error object to the catch function is provided.

The error object consists of the following three properties:

  • message an error message
  • response (optional) the response object
  • body (optional) the response body

Example:

const spmClient = require('spm-client')
spmClient.get('/p/config', {
  json: true
})
  .then(body => {
    console.log(body)
  })
  .catch(error => console.log(error.message))

The example above sets the request parameter json: true. This setting sets the request content type to JSON, and will parse the text response body automatically as JSON.

Include URL-encoded form content in a request

The SAP Signavio Process Manager API often requires you to send a request body as a URL encoded form. You can use the request parameter form to provide the body for the request.

Example:

const spmClient = require('spm-client')
spmClient.post('/path/to/endpoint', {
  form: {
    key: 'value'
  }
})
  .then(body => {
    console.log(body)
  })
  .catch(error => {
    console.log(error.message)
  })

Extract a diagram attribute from a model

The following example extracts the diagram attribute processowner from a model in SAP Signavio Process Manager. The property modelId is provided via a variable from the workflow.

Example:

const spmClient = require('spm-client')
spmClient
  .get(`/p/model/${modelId}/json`, { json: true })
  .then(model => { 
    // You can also log the diagram properties if you are looking for a specific property  
    // be aware all custom attribute names start with 'meta-'  console.log(model.properties)

    // notation to extract default attribute named "processowner"
    processOwner = model.properties.processowner

    // notation to extract custom attribute named "additionalInformation"
    customAttribute = model.properties['meta-additionalInformation']
  })
  .catch(error => {
    console.log(error.message)
  })