Post

2 followers Follow
0
Avatar

Cookies and the REST API

I am attempting to create an interface in Alteryx to allow retrieval and updating of certain elements within Clarizen. I have been able to login and get a sessionId '{"sessionId":"84a39abe-32f0-4db7-bf75-f1534d1ac432_1381473","userId":"f751edd8-b7d2-48d8-a529-c32585306669","organizationId":"f226cfba-6c53-4ca0-9e23-9c27cc1ab17d","serverTime":"2016-11-23T18:03:15.6119854Z","licenseType":"Full"}' but when attempting to use other services with that sessionId I am receiving a message saying '{"errorCode":"LoginFailure","message":"Authentication cookie is missing. Did you forget to login?","referenceId":"3BqHOsNIl2h3AQbT8oDSpU"}'

Any ideas on how I can get passed this?  I am not working within a browser, so no cookies are actually being created.  If needed, I could directly write my own cookie, but I don't know what the structure of that cookie should be.

Any help with this would be appreciated.

Thanks,

Daniel Kelly Answered

Please sign in to leave a comment.

5 comments

0
Avatar

Hi Daniel,

I guess the error message about the cookies was truly not very helpful.

The real cause here is this: The authorization information should be in the request headers. Looking at our logs it seems you placed it in the post body, so the REST API handler could not use it. 

Please refer to the documentation for more information.

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink
0
Avatar

Thanks for the quick response, Ophir.  That did the trick.  

Daniel Kelly 0 votes
Comment actions Permalink
0
Avatar

Hey Ophir,

I got passed that issue.  Now I need to update some custom variables for a particular Project.  I am using the sessionId for Authorization in the Header and using a query against https://api2.clarizen.com/v2.0/services/data/entityQuery of {"typeName": "Project","fields": ["C_VoterFileCount","C_EthnicityCount","C_ExperianRecords","C_StandardPhoneCount","C_WirelessPhoneCount","C_ExperianReporting","C_EmailCount","C_CoopData"],"where": {"and": [{"leftExpression":{"fieldName": "SYSID"},"operator": "Equal","rightExpression": {"value": "P-60506"}}]}} in the Body. The 'P-60506' will be variable in this process.

This returns {"entities":[{"id":"/Project/1ls3h6wp6bjq081v9c20u054w5385","C_VoterFileCount":100.0,"C_EthnicityCount":null,"C_ExperianRecords":null,"C_StandardPhoneCount":null,"C_WirelessPhoneCount":null,"C_ExperianReporting":null,"C_EmailCount":null,"C_CoopData":{"id":"/C_ProjectCoopData/Unknown"}}],"paging":{"from":1,"limit":100,"hasMore":false}} in the Download Data.  The next step I need to do is update each of the C_ values for that Project.  I suppose this should be a fairly simple operation but my lack of experience is making it difficult.  I was thinking I would just have to hit the Project object with https://api2.clarizen.com/v2.0/services/data/object/Project/1ls3h6wp6bjq081v9c20u054w5385 and set the body to update like ["C_VoterFileCount":100.0] but that is not getting me anywhere.  Any insight into this would be appreciated.

Thanks

Daniel Kelly 0 votes
Comment actions Permalink
0
Avatar

Thanks again, Ophir.  Second pair of eyes always seems to point out the what should be obvious. :)

That data/objects page is the holy grail for what I have been tasked to do.

Thanks for the help,

Dan

Daniel Kelly 0 votes
Comment actions Permalink