1

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?

Javaz81
  • 13
  • 3
  • ProcessMaker 4 has native SDKs for exactly this use case! If you want to learn more about our SDKs that interact with the API, we have a Livestream tomorrow on precisely this topic. You would gain a lot of value by tuning in if you can or watch the recording on our channel later. https://youtu.be/rR79byOjSYo – Ethan Presberg Sep 29 '22 at 12:32

1 Answers1

0

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.

osantos
  • 352
  • 2
  • 18
  • yeah I see it but I can't figure auth how to manage authentication. With PM3 I could create OAuth clientID for my third party application easily. If I enter as administrator i see Auth Client section, but I don't know how to create client ID and key to let my third party app use it as authentication. Some example? – Javaz81 Sep 28 '22 at 12:51
  • Did you already create an Authenticated client as described in https://processmaker.gitbook.io/processmaker/processmaker-administration/auth-client-management/manage-client-authentications/create-a-new-client-authentication-key ? – osantos Sep 28 '22 at 19:23
  • I have extended my answer. Hope this helps. This is for basic password authentication. – osantos Sep 28 '22 at 21:05
  • Yeah! It worked. That's what I needed!. I used OkHttp and Gson library to build a simple java app that authenticates and does a GET on environment variables for testing. Thanks so much! – Javaz81 Sep 29 '22 at 08:19
  • I am glad it worked. I am new to processmaker, do you have experience developing PHP scripted tasks in processmaker? – osantos Sep 29 '22 at 09:57
  • Sorry for the late reply, but I rarely log in SO in these period of my life. I'm very sorry, but I really do not have any experience in PHP scripting, so I can't be of any help. – Javaz81 Aug 23 '23 at 06:55