CMDBuild Forum

Restful API with cmdbuild ready2use (CMDBuild READY2USE 2.0-3.2-b)

Hello,

I’m trying to work with the REST API in CMDBuild READY2USE 2.0-3.2-b.
I have created a user api with password api and scope service.
I’m trying to create a session for the user sending a request:
http://localhost:8080/ready2use/services/rest/v3/sessions?scope=service
Content-Type: application/json
username: api
password: api
I’m getting a 200 response with:
{
“success”: true,
“data”: {
“_id”: “current”,
“username”: “api”,
“userId”: 745308,
“userDescription”: “api”,
“role”: “SuperUser”,
“availableRoles”: [
“SuperUser”
],
What bothers me is the _id field that says current, and not a sessionid as explained in the documentation.
When I try to run another request and simply provide current as sessionid it’s not working …

What am I missing?

Thank you very much in advance

Alex

Hello,

when looking at the source code I see in the class
org.cmdbuild.service.rest.v3.endpoint.SessionWS
in the method
private FluentMap<String, ?> serializeSession

that the _id field is initialized by a static value “current”.

return (FluentMap) map(
                "_id", "current",

Should that not be “_id”, session.getSessionId()

Regards,

Alex

Hello,

I finally managed to compile the code with that one line changed and now the API is working as expected.

What is the best way to contribute?

I downloaded the source code from sourceforge because I couldn’t find it on github, only an old version on bitbucket.

Cheers,

Alex

Hi,
due to security issues a new parameter in the Session endpoint has been added to avoid returning the session id. The query parameter is returnId and its default is false, if you pass it in the request with a true value the _id field will be correctly displayed in the response.

I’ll update the webservice documentation and add this parameter in the next days.

Hi,

thank you very much for the information.

Indeed that works.

Regards,

Alex