401 error while making ZAPI Cloud API requests

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.

Unauthorized (401)

org.apache.http.client.ClientProtocolException: Unexpected response status: 401


Check the below cause and rectify it to resolve the issue.

  1. 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.
  2. AccessKey and JIRA username are correct as you see in JIRA
  3. Using the correct JWT token which is generated for a particular API. Each API has a separate JWT token.
  4. JWT token is generated for the correct API,  the same API is used while making the request.
  5. 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.

For Example

  1. If you generate JWT for raw API and make request with param values included, you will get 401 exception.
  2. If you generate JWT token for an API and change the values in the API while making the request, you will get 401 exception.
  3. 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.