How to add new registers inside a given section using OData

Hello community,

 

I want to add data inside a section with the OData interface. I've already checked the documentation at https://documenter.getpostman.com/view/10204500/SztHX5Qb?version=latest and https://academy.creatio.com/docs/developer/integrations_and_api/data_se… but I have the following problem:



I am using a simple Python script to make the API requests in these steps:

 

1. Authenticate in the website using the Authentication method

This works nice using the credentials as payload inside the request.

 

2. Extract the cookie returned inside the header response.

From the test I've made, I need to extract the cookie parts UserName, BPMCSRF, .ASPXAUTH, BPMLOADER and append all of them inside a "Cookie" header like this example:

 

"Cookie: BPMLOADER=; UserType=General; UserName=; .ASPXAUTH=; BPMCSRF=;"

 

Everywhere I've checked inside the documentation it says that it is enough using a header called BPMCSRF with that value from the Set-Cookie response header, but in my case it fails using that value and I have to build the Cookie myself with the different values specified above.

 

3. Perform a POST request to a section like https://mycreatio.com/0/odata/Case

Here the request fails and I get an error 403 - Forbidden with the following message:

 

403 - Forbidden: Access is denied.

You do not have permission to view this directory or page using the credentials that you supplied.

 

And I don't understand why Creatio returns that error, because if I try doing a GET request to the same URL it returns the full list without any problem, but performing a POST request using the same cookie structure inside the headers doesn't return the expected inserted register.

 

Thanks in advance in for your help.

 

Regards.

Like 0

Like

3 comments

Just to clarify, in theory the issue is not related to user permissions as I have tried to insert registers with multiple users (one of them being Supervisor) and in multiple sections, but I always get the same error.

 

P.D. I am using OData 4

Hello Alejandro!

 

For correct requests, you need to use all cookies not "only a part". Also "BPMCSRF" must be used in cookies and as a separate parameter in the header as mentioned in the example here Creatio API (getpostman.com).

Please try and test it with the corresponding changes.

Hello Kyrylo,

 

Thank you very much for your help. In my case the problem was only with that "BPMCSRF" header that I was not building properly, for the cookie values that I have to pass inside the "Cookie" header I tried passing ALL the values extracted from the response header "Set-Cookie" but it didn't let me authenticate, so the solution that works for me is creating a cookie manually with only the values  UserName, UserType, BPMCSRF, .ASPXAUTH, BPMLOADER that I mentioned before.

 

The POST requests are working flawlessly now. I will try now to upload files using OData following the documentation and I would highly appreciate if you are able to help me again if I have trouble.

 

Thank you very much.

Show all comments