Post

4 followers Follow
0
Avatar

REST API example? Version 2.0 please

I'm looking for a REST API version 2 sample.

I have my session id and I see the documentation on commands. Now all I need is some sample code that will allow me to get data.

I'm expecting this sample code to be in two parts.

Part 1 - all the parameters that need to be set
Part 2 - the code that would include the sessionid and commands.

Much appreciated!

Tim Chandler Answered

Official comment

Avatar

Hi Tim,

Please review the REST API 2.0 guide on here

The reference documentation also contains samples of REST API messages. I recommend you check the objects, EntityQuery & Query particularly.

You can also find numerous samples with the REST API in other posts in this forum.

 

Note that the session ID is to be sent in the authorization header of each message.

If you need further assistance, don't hesitate to post or comment again. Please specify what platform/language you use and what you want to achieve with the API so we can come up with answers that are most relevant to your scenario.

Hope this helps,

Ophir

 

Ophir Kenig
Comment actions Permalink

Please sign in to leave a comment.

4 comments

0
Avatar

Thanks Ophir.

I've read that pages more than once and I have to tell you I do not see any examples of using the sessionIDparrameters and commands to read data. 

Could I ask of you to add to this post an example of REST API code that uses the seesionID, parameter settings and a simple command? Once I have your syntax down with the correct parameter settings I should be good to go.

Thanks,

Tim

Tim Chandler 0 votes
Comment actions Permalink
1
Avatar

Hi Tim,

Not sure what kind of examples are you looking for, but the following should hopefully get you started (Examples are using 'curl' - if you expect something else, let me know)

Login:

curl -d "{userName:'YYY',password:'XXX'}" https://api2.clarizen.com/v2.0/services/authentication/login

respone is (sessionId is the important part):

{
"sessionId": "abcdefghijklmnopq_3422",
"userId": "xxx",
"organizationId": "yyy",
"serverTime": "2016-02-08T09:59:26.0510727Z",
"licenseType": "Full"
}

check that you are able to call the api under while authenticated:
curl -H "Authorization: Session abcdefghijklmnopq_3422" https://api2.clarizen.com/v2.0/services/authentication/GetSessionInfo

...

 

perform a query that returns tasks in order of creation:

curl -H "Authorization: Session abcdefghijklmnopq_3422" https://api2.clarizen.com/v2.0/services/data/query -d "{q:'select name,CreatedOn from task order by CreatedOn desc'}"

 

Eyal Post 1 vote
Comment actions Permalink