# Crear caso con api rest

**URL:** <https://community.ofelia.com/t/crear-caso-con-api-rest/11366>\
**Category:** Q&A\
**Created:** [3 October 2022 20:47 UTC](https://community.ofelia.com/t/crear-caso-con-api-rest/11366 "2022-10-03T20:47:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![weglineduardo](https://avatars.discourse-cdn.com/v4/letter/w/85f322/32.png) [@weglineduardo](https://community.ofelia.com/u/weglineduardo)\
**Post date:** [3 October 2022 20:47 UTC](https://community.ofelia.com/t/crear-caso-con-api-rest/11366/1 "2022-10-03T20:47:16Z")

</div>

Hola a todos.  
quiero crea un caso con la api rest.  
Primero me logueo ok con http://localhost:8080/bonita/loginservice y obtengo la cookies

Luego trato de crea el caso con un &nbsp;POST a la url  
http://localhost:8080/bonita/API/bpm/case

usando postman. Me devuelve un status code 401 no autorizado.  
Este es el codigo de postman&nbsp;

var axios = require('axios');  
var data = JSON.stringify({  
&nbsp; "processDefinitionId": "7612481195189194033",  
&nbsp; "variables": [  
&nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; "name": "prestationContract",  
&nbsp; &nbsp; &nbsp; "value": [  
&nbsp; &nbsp; &nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "name": "montantAvance",  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "value": "150"  
&nbsp; &nbsp; &nbsp; &nbsp; },  
&nbsp; &nbsp; &nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "name": "modePerception",  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "value": "Virement"  
&nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; ]  
&nbsp; &nbsp; }  
&nbsp; ]  
});

var config = {  
&nbsp; method: 'post',  
&nbsp; url: 'http://localhost:8080/bonita/API/bpm/case',  
&nbsp; headers: {&nbsp;  
&nbsp; &nbsp; 'Content-Type': 'application/json',&nbsp;  
&nbsp; &nbsp; 'Cookie': 'bonita.tenant=1; BOS\_Locale=es; JSESSIONID=2B622A17A403683551A58FF87AC47CB3; X-Bonita-API-Token=ccf7c15f-d8ec-4a2c-a0e8-c87e4dd28673'  
&nbsp; },  
&nbsp; data : data  
};  
¿alguna ayuda disponible ?  
&nbsp;

---

<div class="post-metadata">

**Author:** ![thalia.cruz](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/thalia.cruz/32/1230_2.png) [@thalia.cruz](https://community.ofelia.com/u/thalia.cruz)\
**Post date:** [21 October 2022 15:14 UTC](https://community.ofelia.com/t/crear-caso-con-api-rest/11366/2 "2022-10-21T15:14:13Z")

</div>

Hola&nbsp;[weglineduardo](http://community.ofelia.com/users/weglineduardo "View user profile."),

He checado la documentación y había un error en un link que no llevaba al lugar indicado para tu caso. Lo estamos corrigiendo.

Hay que hacer referencia a esta página:&nbsp;[https://documentation.bonitasoft.com/bonita/2022.2/api/actors-process-co...](https://documentation.bonitasoft.com/bonita/2022.2/api/actors-process-connectors-api#start-a-process-using-an-instantiation-contract)

- Usa&nbsp;`POST /API/bpm/process/:processId/instantiation`
- Asegúrate que estos&nbsp;2 headers son enviados &nbsp;`JSESSIONID`&nbsp;y&nbsp;`X-Bonita-API-Token`&nbsp;

Lo he intentado con postman y funciona.

¡Espero que esto te ayude!

saludos

---

<div class="post-metadata">

**Author:** ![thalia.cruz](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/thalia.cruz/32/1230_2.png) [@thalia.cruz](https://community.ofelia.com/u/thalia.cruz)\
**Post date:** [26 October 2022 07:38 UTC](https://community.ofelia.com/t/crear-caso-con-api-rest/11366/3 "2022-10-26T07:38:44Z")

</div>

Ok, te falta que estos&nbsp;2 headers sean enviados&nbsp;`JSESSIONID`&nbsp;y&nbsp;`X-Bonita-API-Token`, no sólo en la coookie:

`headers: { `

`'Content-Type': 'application/json', `

`'Cookie': 'bonita.tenant=1; BOS_Locale=es; Cookie_1=value', `

`'JSESSIONID':'283B51C193EB8F1FE4C663BDB6C69884', `

`'X-Bonita-API-Token':'f83758a0-3335-4565-b7c8-b7be746af75d'}`

Así me ha funcionado con postman

Podrías intentarlo y decirme si funciona, por favor?

---

<div class="post-metadata">

**Author:** ![thalia.cruz](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/thalia.cruz/32/1230_2.png) [@thalia.cruz](https://community.ofelia.com/u/thalia.cruz)\
**Post date:** [26 October 2022 13:30 UTC](https://community.ofelia.com/t/crear-caso-con-api-rest/11366/4 "2022-10-26T13:30:23Z")

</div>

I see it in your headers but if I'm not mistaken they're inside the ' **Cookie'** header:

headers: {

'Content-Type': 'application/json',

**'Cookie':**'bonita.tenant=1; BOS\_Locale=es; Cookie\_1=value; JSESSIONID=2C0B8720109952A807DCD0F81AC9E7DE; X-Bonita-API-Token=a956dfc5-9147-4d8a-8131-805004164c07'

}

My recommendation is to send them outside of ' **Cookie'** ,&nbsp;as **2 separate headers** like this:

headers: {

'Content-Type': 'application/json',

**'Cookie':**'bonita.tenant=1; BOS\_Locale=es; Cookie\_1=value',

**'JSESSIONID':**'2C0B8720109952A807DCD0F81AC9E7DE',

**'X-Bonita-API-Token'** :'a956dfc5-9147-4d8a-8131-805004164c07'

}

On my side this is working with walter.bates profile and postman

---

<div class="post-metadata">

**Author:** ![weglineduardo](https://avatars.discourse-cdn.com/v4/letter/w/85f322/32.png) [@weglineduardo](https://community.ofelia.com/u/weglineduardo)\
**Post date:** [4 November 2022 17:21 UTC](https://community.ofelia.com/t/crear-caso-con-api-rest/11366/5 "2022-11-04T17:21:47Z")

</div>

Hello. I solved them with your instructions. good job, thanks

---

<div class="post-metadata">

**Author:** ![weglineduardo](https://avatars.discourse-cdn.com/v4/letter/w/85f322/32.png) [@weglineduardo](https://community.ofelia.com/u/weglineduardo)\
**Post date:** [25 October 2022 23:13 UTC](https://community.ofelia.com/t/crear-caso-con-api-rest/11366/6 "2022-10-25T23:13:42Z")

</div>

Hello.  
I worked with your recommendation and it did not work  
Install pretty studio 2022.2 because the link you recommended was for that version.  
With this I make sure that the installation is clean, without permission errors.

I do this.  
1)

I get the process id  
get&nbsp;  
http://localhost:63066/bonita/API/bpm/process?c=10&p=0

&nbsp;{  
&nbsp; &nbsp; &nbsp; &nbsp; "displayDescription": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "deploymentDate": "2022-10-25 19:36:23.335",  
&nbsp; &nbsp; &nbsp; &nbsp; "displayName": "Incidente",  
&nbsp; &nbsp; &nbsp; &nbsp; "name": "Incidente",  
&nbsp; &nbsp; &nbsp; &nbsp; "description": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "deployedBy": "4",  
&nbsp; &nbsp; &nbsp; &nbsp; "id": " **5063742355450000882**",  
&nbsp; &nbsp; &nbsp; &nbsp; "activationState": "ENABLED",  
&nbsp; &nbsp; &nbsp; &nbsp; "version": "1.0",  
&nbsp; &nbsp; &nbsp; &nbsp; "configurationState": "RESOLVED",  
&nbsp; &nbsp; &nbsp; &nbsp; "last\_update\_date": "2022-10-25 19:36:23.702",  
&nbsp; &nbsp; &nbsp; &nbsp; "actorinitiatorid": "125"  
&nbsp; &nbsp; }  
&nbsp;&nbsp; &nbsp;  
2)I make a post

http://localhost:63066/bonita/API/bpm/process/ **5063742355450000882** /instantiation

{  
&nbsp; &nbsp; "searchIndex5Label": "",  
&nbsp; &nbsp; "searchIndex3Value": "",  
&nbsp; &nbsp; "searchIndex4Value": "",  
&nbsp; &nbsp; "searchIndex2Label": "",  
&nbsp; &nbsp; "searchIndex1Value": "",  
&nbsp; &nbsp; "searchIndex3Label": "",  
&nbsp; &nbsp; "startedBySubstitute": "4",  
&nbsp; &nbsp; "searchIndex5Value": "",  
&nbsp; &nbsp; "searchIndex2Value": "",  
&nbsp; &nbsp; "state": "started",  
&nbsp; &nbsp; "searchIndex1Label": "",  
&nbsp; &nbsp; "started\_by": "4",  
&nbsp; &nbsp; "searchIndex4Label": ""  
}

401 Unauthorized

and cookies are sent

headers: {&nbsp;  
&nbsp; &nbsp; 'Content-Type': 'application/json',&nbsp;  
&nbsp; &nbsp; 'Cookie': 'bonita.tenant=1; BOS\_Locale=es; Cookie\_1=value; JSESSIONID=283B51C193EB8F1FE4C663BDB6C69884; X-Bonita-API-Token=f83758a0-3335-4565-b7c8-b7be746af75d'  
&nbsp; },

3) I bring the things created with the bpm and the processDefinitionId is correct.  
&nbsp;&nbsp; &nbsp;  
http://localhost:63066/bonita/API/bpm/case/

[  
&nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; "end\_date": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex5Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "processDefinitionId": " **5063742355450000882**",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex3Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex4Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex2Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "start": "2022-10-25 19:37:08.419",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex1Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex3Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "startedBySubstitute": "4",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex5Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex2Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "rootCaseId": "8",  
&nbsp; &nbsp; &nbsp; &nbsp; "id": "8",  
&nbsp; &nbsp; &nbsp; &nbsp; "state": "started",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex1Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "started\_by": "4",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex4Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "last\_update\_date": "2022-10-25 19:37:08.419"  
&nbsp; &nbsp; },  
&nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; "end\_date": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex5Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "processDefinitionId": " **5063742355450000882**",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex3Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex4Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex2Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "start": "2022-10-25 19:53:59.399",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex1Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex3Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "startedBySubstitute": "4",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex5Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex2Value": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "rootCaseId": "9",  
&nbsp; &nbsp; &nbsp; &nbsp; "id": "9",  
&nbsp; &nbsp; &nbsp; &nbsp; "state": "started",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex1Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "started\_by": "4",  
&nbsp; &nbsp; &nbsp; &nbsp; "searchIndex4Label": "",  
&nbsp; &nbsp; &nbsp; &nbsp; "last\_update\_date": "2022-10-25 19:53:59.399"  
&nbsp; &nbsp; }  
]

please can you share the custom-permissions-mapping.properties , resources-permissions-mapping-custom.properties and compound-permissions-mapping-custom.properties files of your  
installation so I verify the permissions you have?

According to the documentation here https://documentation.bonitasoft.com/bonita/2022.1/identity/rest-api-authorization#static\_authorization they are needed to use the rest api

Send to this email please weglineduardo@hotmail.com

---

<div class="post-metadata">

**Author:** ![weglineduardo](https://avatars.discourse-cdn.com/v4/letter/w/85f322/32.png) [@weglineduardo](https://community.ofelia.com/u/weglineduardo)\
**Post date:** [26 October 2022 13:01 UTC](https://community.ofelia.com/t/crear-caso-con-api-rest/11366/7 "2022-10-26T13:01:06Z")

</div>

Hello. I sent them too. I mentioned those two only because you told me above that I should not forget to send them. Postman sends them. i have this in postman

var&nbsp;axios&nbsp;=&nbsp;require('axios');

var&nbsp;data&nbsp;=&nbsp;JSON.stringify({

&nbsp;&nbsp;"searchIndex5Label":&nbsp;"",

&nbsp;&nbsp;"searchIndex3Value":&nbsp;"",

&nbsp;&nbsp;"searchIndex4Value":&nbsp;"",

&nbsp;&nbsp;"searchIndex2Label":&nbsp;"",

&nbsp;&nbsp;"searchIndex1Value":&nbsp;"",

&nbsp;&nbsp;"searchIndex3Label":&nbsp;"",

&nbsp;&nbsp;"startedBySubstitute":&nbsp;"4",

&nbsp;&nbsp;"searchIndex5Value":&nbsp;"",

&nbsp;&nbsp;"searchIndex2Value":&nbsp;"",

&nbsp;&nbsp;"state":&nbsp;"started",

&nbsp;&nbsp;"searchIndex1Label":&nbsp;"",

&nbsp;&nbsp;"started\_by":&nbsp;"4",

&nbsp;&nbsp;"searchIndex4Label":&nbsp;""

});

&nbsp;

var&nbsp;config&nbsp;=&nbsp;{

&nbsp;&nbsp;method:&nbsp;'post',

&nbsp;&nbsp;url:&nbsp;'http://localhost:63066/bonita/API/bpm/process/5712791836604956850/instantiation',

&nbsp;&nbsp;headers:&nbsp;{&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;'Content-Type':&nbsp;'application/json',&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;'Cookie':&nbsp;'bonita.tenant=1;&nbsp;BOS\_Locale=es;&nbsp;Cookie\_1=value;&nbsp;JSESSIONID=2C0B8720109952A807DCD0F81AC9E7DE;&nbsp;X-Bonita-API-Token=a956dfc5-9147-4d8a-8131-805004164c07'

&nbsp;&nbsp;},

&nbsp;&nbsp;data&nbsp;:&nbsp;data

};

&nbsp;

axios(config)

.then(function&nbsp;(response)&nbsp;{

&nbsp;&nbsp;console.log(JSON.stringify(response.data));

})

.catch(function&nbsp;(error)&nbsp;{

&nbsp;&nbsp;console.log(error);

});

401 Unauthorized

&nbsp;

It does not work. Just tried again.

do you have any other solution?  
Isn't it something like this? \>\>&nbsp;&nbsp;&nbsp;https://documentation.bonitasoft.com/bonita/2022.1/identity/rest-api-authorization#static\_authorization&nbsp;

thanks for your help  
Cheers

&nbsp;

---

<div class="post-metadata">

**Author:** ![thalia.cruz](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/thalia.cruz/32/1230_2.png) [@thalia.cruz](https://community.ofelia.com/u/thalia.cruz)\
**Post date:** [4 November 2022 18:07 UTC](https://community.ofelia.com/t/crear-caso-con-api-rest/11366/8 "2022-11-04T18:07:32Z")

</div>

Great! I'll mark it as the answer
