Forum Discussion

Radiation's avatar
Radiation
New Member
2 years ago

Procedure to call a zephyr cloud api

Hi SmartBear Team,

I am trying  a simple get request for generalinformation using the zephyr endpoint -> /public/rest/api/1.0/config/generalinformation 

The base url that I have used is -> 

 
I have got my accountId/UserId from jira.
Access Key and Secrets Key from the zephyr squad UI under the APIs keys tab.
 
I am using the below python code
 
# JWT EXPIRE how long token been to be active? 3600 == 1 hour
JWT_EXPIRE = 3600

# BASE URL for Zephyr for Jira Cloud

# RELATIVE PATH for token generation and make request to api
RELATIVE_PATH = '/public/rest/api/1.0/config/generalinformation'


print(BASE_URL+RELATIVE_PATH)


# # CANONICAL PATH (Http Method & Relative Path & Query String)
CANONICAL_PATH = 'GET&'+RELATIVE_PATH+'&'

# TOKEN HEADER: to generate jwt token
payload_token = {
'sub': ACCOUNT_ID,
'qsh': hashlib.sha256(CANONICAL_PATH.encode('utf-8')).hexdigest(),
'iss': ACCESS_KEY,
'exp': int(time.time())+JWT_EXPIRE,
'iat': int(time.time())
}

# GENERATE TOKEN
token = jwt.encode(payload_token, SECRET_KEY, algorithm='HS256').strip().decode('utf-8')

print(token)
 
# REQUEST HEADER: to create cycle
headers = {
'Authorization': 'JWT '+token,
'Content-Type': 'application/json',
'zapiAccessKey': ACCESS_KEY
}

# MAKE REQUEST:
raw_result = requests.request("GET", BASE_URL + RELATIVE_PATH, headers=headers, auth=auth)
if is_json(raw_result.text😞

# JSON RESPONSE: convert response to JSON
json_result = json.loads(raw_result.text)

# PRINT RESPONSE: pretty print with 4 indent
print(json.dumps(json_result, indent=4, sort_keys=True))

else:
print(raw_result.text)
 
 
 
 
However I am getting the below error from the server end
An internal error occurred. Please check the host product's logs.
 
And the postman says this

 

Can someone from the team please help me out, with what is to be done.

No RepliesBe the first to reply