-2

API PROCESSMAKER version 4.1.0 AND 4.1.18

I have a problem with the APIs, either doing the try out from swagger or consuming the API from other code, the error that comes out is unauthenticated, I already tried passing the token of the admin user in the field of pm_api_bearer and also automatically from swagger that is redirected to processmaker for login approval.

To connect or test the api I use the processmaker documentation, which uses https://staging-pm4.processmaker.net/api/documentation. obviously applied to my server https: {server ip of my processmaker} / api / documentation. In the swagger I can log in perfectly using the authorize button, but when I want to try an api in the same place, the result I have is the following:

Error: Unauthorized

I have also tried the api through the console, with curl, passing it the user token created in the processmaker, as the processmaker wiki says on github (https://github.com/ProcessMaker/processmaker/wiki/API-Authentication) but I get the same result.

Curl example:

$ export TOKEN = “your generated token” $ curl -H ‘Accept: application / json’ -H “Authorization: Bearer $ {TOKEN}” {server ip of my processmaker}

in the token in the curl or in the pm_api_bearer (http, Bearer) (PREVIOUS SCREENSHOTS). I introduce the token generated by processmaker in the path admin -> user -> API TOKEN.

swagger api

in the token in the curl or in the pm_api_bearer (http, Bearer) (PREVIOUS SCREENSHOTS). I introduce the token generated by processmaker in the path admin -> user -> API TOKEN.

Braiam
  • 1
  • 11
  • 47
  • 78

2 Answers2

0

The URL provided in the documentation is incomplete. You need to add "/api/1.0" at the end of the URL. In Swagger, you will notice a few Parameters which are required (Cannot be invalid or empty). I suggest you download the API documentation and try to run it using the Postman application before applying it to the ProcessMaker itself (Corrected URL).

Also, the API calls are user-based, that is, if a user does not have access to start the process, you cannot start the process using the Start Process API.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

@Agustin Modia posted this same question as an issue in processmaker's github https://github.com/ProcessMaker/processmaker/issues/3802#issue-891185855

another github user (mindfullofit) provided a response that worked for me:

@agustin-modia-agp Hope all is well. I saw in the Bitnami Community forum where you posted this question but could not respond since it is currently closed. Since you are using the Bitnami Stack, please know that the Apache configuration is stripping the Authorization header. So, even though you are able to get an access token using OAuth2, you will receive the 401 error. To fix it, you will need to adjust either your .htaccess file or modify your processmaker-vhost.conf file. The .conf file is located in your server at /opt/bitnami/apache2/conf/vhosts . There is also one for the SSL version of the application. Here's an example of how to modify the .htaccess on SO (https://stackoverflow.com/a/53382434/8424510) . Best wishes!

I modified the vhost.conf file to include:

RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

below the other RewriteCond elements that where at the end of the file. Those apply at the VirtualHost level, not Directory level.

Don't forget to restart at least Apache service. I did it with the command:

sudo /opt/bitnami/ctlscript.sh restart apache