Home > front end >  How to write a Java application with processMaker 4.0 API?
How to write a Java application with processMaker 4.0 API?

Time:09-29

Good morning,

i have downloaded and install the pm4-core docker image and installed it. I can run PM4, create and admin my pm4 instance without issues, but i want to develop a java program that uses the PM 4 restful API to edit some process data. I search on YouTube but I have found something about restful api usage with PM 3.2 not 4. Furthermore, in the "Auth client" section, the "Enable direct API access" option is missing.

Does someone have a simple piece of code written in java,kotlin, C#, swift etc... that authenticates and use restful PM4 API to share with?

CodePudding user response:

You can access the restful API documentation by logging into processmaker 4 and then accessing the following url http://youserver:yourport/api/documentation. You shoud get a swager screen where you can see the Restfull endpoints and the parameters they take. You can even execute the calls from there if you click on the autorize button. enter image description here

In order to be able to authenticate to access the API you first need to create an Auth Client and enable password grant.

Once you create an Auth client take note of the Client ID (the number not the name you provided when creating the client), and the secret.

You can obtain the access_token and the refresh_tokens by making a post request to the url https://yourhostname/oauth/token with content type "application/json" and the following body contents:

{
  "grant_type": "password",
  "scope": "*",
  "client_id": 6,
  "client_secret": "zBBO.........30p0iHQ3",
  "username": "yourusername",
  "password": "yourpassword"
}

Of course you must replace the client_id, the secret, the username and password to your specific values.

  • Related