Post

4 followers Follow
1
Avatar

REST API Login failure when using Primary APIKEY

Hello,

Has anyone tried accessing Clarizen REST API using APIKEY?

I am calling the following API using APIKEY in the header and getting login failure

https://api2.clarizen.com/v2.0/services/data/query?q=SELECT createdOn,title FROM Issue WHERE createdOn>2020-03-01

Error message:

   "errorCode": "LoginFailure",
    "message": "You are not authorized to access this service."
 
Thank you in advance for your help.
 
Regards,
KS
Ksave Answered

Please sign in to leave a comment.

9 comments

0
Avatar

Hi Roland,

 

Thank you for your reply to my post. I followed the steps mentioned in your post and now I am getting this error... Is there another parameter or setting that I need to set or configure?

 

Thank you in advance.

{

    "errorCode": "Internal",
    "message": "An internal error has occurred, the error was logged and will be examined.",
    "referenceId": "3GH2SmYVsxxxxxxxxxxxxxx"
}
 
 
Ksave 0 votes
Comment actions Permalink
0
Avatar

Hi there,

Could you please provide screenshots of your authentication call (body and headers) and the subsequent query call (body and headers)?

Thank you,

Roland

Roland Pumputis 0 votes
Comment actions Permalink
0
Avatar

Hi Roland,

 

Thank you again for your response.

On second try, I am able to login now. The issue was with the content-type. I was using JSON, whereas it needs to be text/plain. Once I changed the content type, login worked.

But when using Session ID, i tried to access Issue query as shown below and I am getting authorization error. I have also attached screen print for the same.

I am able to access Issues from front end

Can you please let me know if we are missing anything for the user setting to be able to query Issue via API?

 

https://api2.clarizen.com/v2.0/services/data/query?q=SELECT createdOn,title FROM Issue WHERE createdOn>2020-03-01

 

 "errorCode": "LoginFailure",
    "message": "You are not authorized to access this service.",
 
 
 
 
Ksave 0 votes
Comment actions Permalink
1
Avatar

Hi there,

Please try this:

 

This is what my headers look like:

I hope this helps.

Roland

Roland Pumputis 1 vote
Comment actions Permalink
0
Avatar

Hi Roland,

 

Removing APIKEY from Issues API call and appending Session in front of SessionID worked.

I am able to make calls now using V2 REST API.

Thank you for your responses.

Regards,

Kaustubh

Ksave 0 votes
Comment actions Permalink
0
Avatar

@Roland, 

If @Kaustubh has to remove the APIKEY attribute, and instead has to login with username and password and then use the Session ID from that call, what is the purpose of the APIKEY in the first place? 

Can you please explain exactly how one is supposed to use the APIKEY to create a login session? I was under the impression from the documentation that you simply pass the APIKEY in each call to forego the need to login.

More detailed documentation would be greatly appreciated.

Chad Davis 0 votes
Comment actions Permalink
0
Avatar

Hi Chad,

You can use API keys now. Initially we only had the Username/Password > Session authentication. If you want to use an API key instead, just add the following key/value pair to your headers: "Authorization": "ApiKey xxx" where xxx is your actual API key.

I hope this helps.

Roland

Roland Pumputis 0 votes
Comment actions Permalink
0
Avatar

@Roland, thank you! That's the piece I was missing.

I had been trying this:

curl -X GET "https://api2.clarizen.com/v2.0/services/authentication/GetSessionInfo" -H "ApiKey: XXX"

Which would give me this error:

{"errorCode":"LoginFailure","message":"You are not authorized to access this service.","referenceId":"XXX"}

 

This was what I needed instead:

curl -X GET "https://api2.clarizen.com/v2.0/services/authentication/GetSessionInfo" -H "Authorization: ApiKey XXX"

 

Hopefully this helps others with the same issue.

Chad Davis 0 votes
Comment actions Permalink