January 11, 2017
Getting 401 error while making request to ZAPI Cloud using API's
You may get below exceptions when making ZAPI Cloud calls. These exceptions are due to invalid credentials passed.
org.apache.http.client.ClientProtocolException: Unexpected response status: 401
Check the below cause and rectify it to resolve the issue.
- Using JIRA URL instead of ZAPI Cloud URL, should not use the JIRA URL for making ZAPI Cloud requests. ZAPI Cloud and JIRA URL are different.
- AccessKey and JIRA username are correct as you see in JIRA
- Using the correct JWT token which is generated for a particular API. Each API has a separate JWT token.
- JWT token is generated for the correct API, the same API is used while making the request.
- Using the same API for which the JWT is generated while making request. JWT token should generated for the API after providing the values of parameters.
- If you generate JWT for raw API and make request with param values included, you will get 401 exception.
- If you generate JWT token for an API and change the values in the API while making the request, you will get 401 exception.
- For API "https://test.zapicloud.com/connect/public/rest/api/1.0/cycle/?versionId=&projectId=" the JWT token is generated after providing the param values like "https://test.zapicloud.com/connect/public/rest/api/1.0/cycle/0001481885181917-242ac112-0001?versionId=10000&projectId=10000"
If the issue persists after checking all the above, please submit a case with us.