Starting a Request via REST API
Learn how to start an instance of a Process called a Request.
Last updated
Learn how to start an instance of a Process called a Request.
Last updated
© 2024 ProcessMaker, Inc. All Rights Reserved. Except as otherwise permitted by ProcessMaker, this publication, or parts thereof, may not be reproduced in any form, by any method, for any purpose.
This guide walks you through the steps to create a new Process instance, called a Request, using the ProcessMaker 4 REST API programmatically. The guide assumes that you already have an access token for authenticating your API requests. If you need a refresher on obtaining an access token, you can refer to the previous guide here.
Requirement | Function | Version |
---|---|---|
Before starting, ensure that you have Python 3 and the requests
library installed. You can verify your Python version by typing python --version
in your command line. The requests
library can be installed via pip, Python's package manager, with the command pip install requests
.
If the command python
returns an error, it may be installed as python3,
depending on your environment.
The ProcessMaker 4 REST API uses HTTP protocols, and in this case, we will be sending a POST request to create a new request. For this, we must prepare the headers and the body of our request.
The headers of an HTTP request provide additional parameters that the request needs to fulfill. In our case, we need to provide the Authorization
header with our access token to authenticate our request.
In Python, headers are represented as a dictionary with the header names as keys and the corresponding values as dictionary values.
Here's how you would set up the headers:
Replace {access_token}
with your actual access token.
The body of a POST request contains the data we want to send to the server. In this case, we'll use a blank dictionary ({}
) however this is dependent on your process, you may require to send additional parameters to be used as request data within the request.
Here's an example of a blank request body:
Now that we have our headers and request body ready, we can send our POST request to the ProcessMaker 4 REST API.
The URL for creating a new process instance is https://<your-instance>/api/1.0/process_events/<process_id>
. Replace <your-instance>
with your actual ProcessMaker instance and <process_id>
with the ID of the process you want to start.
Here's how you can send the POST request and print the response:
The response.json()
function converts the server's response from a JSON format to a Python dictionary for easier handling.
That's it! You now know how to create a new process instance using the ProcessMaker 4 REST API in Python. Remember to replace <your-instance>
, <your-access-token>
, and <process_id>
with actual values.
If you need help obtaining the process id, you can look at the to get the id before making the request to initiate a new request.
Requirement | Function | Version |
---|---|---|
If you need help obtaining the process id, you can look at the to get the id before making the request to initiate a new request.
Requirement | Function | Version |
---|---|---|
Requirement | Function | Version |
---|---|---|
Python Dependencies:
requests
The programming language and modules we are using for this tutorial
Python 3+ Requests will install default latest version which is fine.
Access token
For authenticating with the API.
instructions for obtaining from the How to Get an Access Token page
Node.js Dependencies:
axios
The programming language and modules we are using for this tutorial
Nodejs 8+
NPM 8-16
Note: this is the ProcessMaker compatible version, this tutorial should work with the latest versions as well.
Access token
For authenticating with the API.
instructions for obtaining from the How to Get an Access Token page
Postman
The tool we will use to make API calls to ProcessMaker 4 REST API
Latest
Access token
For authenticating with the API.
instructions for obtaining from the How to Get an Access Token page
Postman or a Terminal
The tool we will use to make API calls to ProcessMaker 4 REST API
Latest
Access token
For authenticating with the API.
instructions for obtaining from the How to Get an Access Token page