Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
Hi Forum,

I’m new to ProcessMaker and want to figure out the REST API to implement my software against it.
At first I use the Advanced REST Client to see if I understood everything well.

Now I have the following problem:
At first everything works well, I registered my App and I get an access_token via
Code: Select all
POST /workflow/oauth2/token HTTP/1.1
HOST: localhost:8081
content-length: 177
content-type: application/json

{"grant_type":"password","scope":"*","client_id":"XXXXNPSQHFJNROHQIKTKGYRUCXJGYMRU","client_secret":"40863037159355cfac04838095272266","username":"admin","password": "p4ssw0rd"}
I get the 200:OK Response like expected
Code: Select all
  "access_token": "271c3cc5c389aaad1166ade7b1fbeba58a7d6d45",
  "expires_in": 86400,
  "token_type": "bearer",
  "scope": "*",
  "refresh_token": "d7b1c47cf394a1c8a1d6a4b021f4962572e97b98"
But when I now try to access the endpoint /cases or /users with
Code: Select all
GET /api/1.0/workflow/cases?Authorization=Bearer%20271c3cc5c389aaad1166ade7b1fbeba58a7d6d45 HTTP/1.1
HOST: localhost:8081
content-type: application/json
I get always an 401:Unautorized error:
Code: Select all
  "error": {
    "code": 401,
    "message": "Unauthorized"
What is wrong?
The user is Supervisor so there should be no restrictions at all.

Last edited by PixelHunter on Tue Jun 06, 2017 4:16 am, edited 1 time in total.
You need to include the access token in your header when calling a REST endpoint:

How are you calling REST? With JavaScript, PHP, Postman plugin for Chrome, httpRequester plugin for Firefox?

For example, in PHP:
Code: Select all
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
If you are using httpRequester, then click on the "Header" tab and set "Authorization" in the Name and "Bearer XXXXXXXXXXXXXXXXXXXXXXXX" in the Value.

Now it's working! :D

I use the Chrome plugin (Adv. REST client) at first, then I will implement it with good old Delphi.
Code: Select all
GET /api/1.0/workflow/cases HTTP/1.1
HOST: cougar:8081
authorization: Bearer 08a73c105a35a7a35c3127e6d0df2f6fdbd14d13
content-type: application/json
My mistake was that I put it as Query Parameters and not in the Header.

Thank you.
REST API Question

I am currently looking at developing a portlet for[…]

Everybody wants to be famous, but nobody wants to […]

Hi, I attached a sample config file, Please check […]

Error clicking on Participated

Hi, I attached a sample config file, Please check […]