# Create case with api rest

**URL:** <https://community.ofelia.com/t/create-case-with-api-rest/11364>\
**Category:** Q&A\
**Created:** [3 October 2022 20:45 UTC](https://community.ofelia.com/t/create-case-with-api-rest/11364 "2022-10-03T20:45:01Z")\
**Posts on this page:** 3\
**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:45 UTC](https://community.ofelia.com/t/create-case-with-api-rest/11364/1 "2022-10-03T20:45:01Z")

</div>

Hello everyone.  
I want to create a case with the rest api.  
First I log in ok with http://localhost:8080/bonita/loginservice and get the cookies

Then I try to create the case with a POST to the url  
http://localhost:8080/pretty/API/bpm/case

using postman. It returns a status code 401 unauthorized.  
This is the postman code

var axios = require('axios');  
var data = JSON.stringify({  
&nbsp; "processDefinitionId": "7612481195189194033",  
&nbsp; "variables": [  
&nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; "name": "performanceContract",  
&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; 'Content-Type': 'application/json',  
&nbsp; &nbsp; 'Cookie': 'pretty.tenant=1; BOS\_Locale=en; JSESSIONID=2B622A17A403683551A58FF87AC47CB3; X-Pretty-API-Token=ccf7c15f-d8ec-4a2c-a0e8-c87e4dd28673'  
&nbsp; },  
&nbsp; date : date  
};  
any help available?

---

<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 14:19 UTC](https://community.ofelia.com/t/create-case-with-api-rest/11364/2 "2022-10-21T14:19:43Z")

</div>

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

I have checked and documentation it was not pointing to the right page for the case that you're trying to achieve. We're currently fixing the links.

Please refer to: https://documentation.bonitasoft.com/bonita/2022.2/api/actors-process-connectors-api#start-a-process-using-an-instantiation-contract

- Use `POST /API/bpm/process/:processId/instantiation`
- Be sure to add both headers `JSESSIONID` and `X-Bonita-API-Token` to your request.

I've tried using postman and it is working for me. Hope this helps!

---

<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:09 UTC](https://community.ofelia.com/t/create-case-with-api-rest/11364/3 "2022-11-04T18:09:26Z")

</div>

As confirmed, here, this is the best answer:&nbsp;http://community.ofelia.com/node/37958#node-38034
