Questions and discussion about using ProcessMaker: user interface, running cases & functionality

Moderator: amosbatto

User avatar
By jemiris
#826178
Hi,

Is there any way to get the process map and its properties via rest API
The attached image below:
processmap-rest.png
processmap-rest.png (68.81 KiB) Viewed 2292 times
User avatar
By amosbatto
#826188
Install my extraRest plugin. Then call GET extrarest/session-id to get the session ID.

Then, you can create a <iframe> whose src is set to the URL:
http://{domain_or_ip}/sys{workspace}/{lang}/{skin}/designer?prj_uid={process_uid}&prj_readonly=true&app_uid={app_uid}&sid={session_id}

Example:
Code: Select all
<iframe src="http://example.com/sysworkflow/en/neoclassic/designer?prj_uid=6135378175a8dcdca9a2641037096319&prj_readonly=true&app_uid=9777918985a8dddbf884236088281261&sid=1234567890abcde1234567890abcde"></iframe>
User avatar
By jemiris
#826199
That's a great answer. Thanks and I have another question that if the session gets expired how can I get another session-id.
I need some clarifications on that. Could you please explain it?
User avatar
By jemiris
#826236
Thanks a lot.
My Questions:
1. How does the endpoint know that when the session get's expiry in the processmaker?
2. As of now, we are mentioning the session-id for any user. So how the rest API gets the session-id?
3. Is it getting the session id of the admin user or how is it getting?
4. Why I have these questions it's because in the web service name called "Automatic Login" https://wiki.processmaker.com/index.php ... atic_Login. In web services, we have to specify the username and password to get the particular user's session id. So my question is how the REST API will the particular user id?
User avatar
By amosbatto
#826249
jemiris wrote: Thu Aug 29, 2019 5:07 am 1. How does the endpoint know that when the session get's expiry in the processmaker?
If the login session has expired (after 24 minutes of inactivity), then when you try to open the process map in an iframe, it will be redirected to the ProcessMaker login screen. The user can login, and then the iframe will redirect back to the process map.
If you want to avoid making the user login manually, then you should call a REST endpoint just to verify that the login session is still valid, before trying to display the process map in an iframe. If the call to the REST endpoint fails, then you need login using oAuth2 and then get a new session ID. Then, use that new session ID to display the process map in an iframe.
jemiris wrote: Thu Aug 29, 2019 5:07 am 2. As of now, we are mentioning the session-id for any user. So how the rest API gets the session-id?
3. Is it getting the session id of the admin user or how is it getting?
You can only get the session ID for the user who logged in using oAuth2. If you logged in as "admin", then you are getting the session ID for "admin". You can't get session IDs for other users.

If you want to do actions for other users, then the extraRest plugin has endpoints for Process Supervisors to do actions like route cases, assign cases, set variables, etc. for other users.
jemiris wrote: Thu Aug 29, 2019 5:07 am 4. Why I have these questions it's because in the web service name called "Automatic Login" https://wiki.processmaker.com/index.php ... atic_Login. In web services, we have to specify the username and password to get the particular user's session id. So my question is how the REST API will the particular user id?
That example from the web services documentation is attaching the session ID to the URL, just like I'm telling you to do with REST.

Web services is the same as REST. You need to login as each user to get his/her session ID.
User avatar
By amosbatto
#826643
jemiris wrote:Yes, I have used this API to get session id and process map.

https://sourceforge.net/p/pmcommunity/c ... session-id

but via rest API it is not the right way to handle it
You can use an <iframe> to display the process map in an external web page like this:
Code: Select all
<iframe src="http://example.com/sysworkflow/en/neoclassic/designer?prj_uid=6135378175a8dcdca9a2641037096319&prj_readonly=true&app_uid=9777918985a8dddbf884236088281261&sid=1234567890abcde1234567890abcde"> 
That doesn't work for you?
User avatar
By amosbatto
#826666
The process map is generated by the Designer::index() function defined in workflow/engine/controllers/designer.php

You can create your own REST endpoint which uses the code in that function.
User avatar
By jemiris
#826700
But this page code renders the HTML page which has dynamic js and CSS files. So it's better to display via iframe.

I have tried via iframe as below
Code: Select all
<iframe id="processMapFrame" name="processMapFrame" src="http://localhost:8080/sysjemiris/en/neoclassic/designer?prj_uid=6946716305d4a85a4125961038662114&prj_readonly=true&app_uid=4552307125d8c7ef5c652e7093079525&sid=7439575195d8cab80466c25035220712" 
    width="100%" height="700px" frameboarder="1px">
x-frame options.png
x-frame options.png (78.84 KiB) Viewed 1868 times
User avatar
By amosbatto
#826703
What version of PM do you have? It used to work.

I assume this is a cross origin problem. In the Designer::index() function defined in workflow/engine/controllers/designer.php, add the following line:
header("Access-Control-Allow-Origin: *");
User avatar
By jemiris
#826707
yes, this works with iframe. But I have included the designer.php file inside my custom REST and it returns the HTML page, not the process map as below
Code: Select all
<!DOCTYPE html>
<head>
    <!-- translations -->
    <script type="text/javascript" src="/translations/translationsMafe.js"></script>


    <link rel="stylesheet" type="text/css" href="/lib/css/mafe-92a59a3-f9f10aa.css" />
    <link rel="stylesheet" type="text/css" href="/css/neoclassic-pm3.css" />
        <script type="text/javascript">
        var prj_uid = "6946716305d4a85a4125961038662114";
        var app_uid = "4552307125d8c7ef5c652e7093079525";
        var consolidated = "0";
        var enterprise = "0";
        var prj_readonly = "true";
        var credentials = "eyJhY2Nlc3NfdG9rZW4iOiI1YTAyNDMzZjQ5YzRmMTUyZWMwNDJjY2ZhMGI3N2VhMDA0NGJiOWRlIiwiZXhwaXJlc19pbiI6ODY0MDAsInRva2VuX3R5cGUiOiJiZWFyZXIiLCJzY29wZSI6InZpZXdfcHJvY2Vzc2VzIGVkaXRfcHJvY2Vzc2VzICoiLCJyZWZyZXNoX3Rva2VuIjoiODM3YTNjZmY4NGE0YWExOWJkM2FmYmM4NzRjZWRmYWE2ZGUzNjhhOCIsImNsaWVudF9pZCI6IngtcG0tbG9jYWwtY2xpZW50IiwiY2xpZW50X3NlY3JldCI6IjE3OWFkNDVjNmNlMmNiOTdjZjEwMjllMjEyMDQ2ZTgxIn0=";
        var distribution = "0";
        var SYS_SYS = "jemiris";
        var SYS_LANG = "en";
        var SYS_SKIN = "neoclassic";
        var HTTP_SERVER_HOSTNAME = "http://localhost:8000";
    </script>
    <script type="text/javascript" src="/lib/js/mafe-92a59a3-f9f10aa.js"></script>
    


</head>
<body onresize="resizingFrame();">
<!--<div class="ui-layout-north">-->
     <div class="loader"></div>
     <section class="navBar" id="idNavBar">
        <div class="head"></div>
        <nav>
            <ul id="idNavBarList">

            </ul>
        </nav>

    </section>
    <div class="bpmn_shapes">
    </div>
<!--</div>-->
<div id="p-center-layout"/>
    <!--BODY-->
    <div class="ui-layout-center tab-content" id="div-layout-canvas">
    </div>

    <section class="content" id="idContent">

        <div class="content_controls">
            <div class="head"></div>
            <ul id="contentControlList">
                
            </ul>
        </div>
        <div class="bpmn_shapes_legend">
            <div class="head"></div>
        </div>
    </section>
<SCRIPT src="/jscore/src/PM.js" type=text/javascript></SCRIPT>
<SCRIPT src="/jscore/src/Sessions.js" type=text/javascript></SCRIPT>
</body>
</html>
ProcessMaker external Editor

Hi all, I am trying to follow how to use Processm[…]

Hi dan123dan, Even though your answer isn't direc[…]

If your plugin uses this (e.g. to insert data into[…]

Processmaker Installation on Linux

We are trying to install processmaker on linux ser[…]