nishanth
2 years agoNew Contributor
Error Code: 137 | Exporting executions download | We have encountered with some minor issue
The below snippets returned with 200 status code containing the Execution Id
<Response [200]>
0001677994347309-242ac113-0001
BASE_URL = 'https://prod-api.zephyr4jiracloud.com/connect'
# RELATIVE PATH for token generation and make request to api
RELATIVE_PATH = '/public/rest/api/1.0/executions/export'
CANONICAL_PATH = 'POST&'+RELATIVE_PATH+'&'
After passing Execution ID to API '/public/rest/api/1.0/executions/export/download/'
Getting
<Response [500]>
{
"clientMessage": "We have encountered with some minor issue. Please try again.",
"errorCode": 137,
"errorType": "ERROR"
}
Complete Snippets:
import json
import jwt
import time
import hashlib
import requests
def is_json(data):
try:
json.loads(data)
except ValueError:
return False
return True
# USER
ACCOUNT_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# ACCESS KEY from navigation >> Tests >> API Keys
ACCESS_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# ACCESS KEY from navigation >> Tests >> API Keys
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# JWT EXPIRE how long token been to be active? 3600 == 1 hour
JWT_EXPIRE = 3600
# BASE URL for Zephyr for Jira Cloud
BASE_URL = 'https://prod-api.zephyr4jiracloud.com/connect'
fileName = '0001677994347309-242ac113-0001'
# RELATIVE PATH for token generation and make request to api
RELATIVE_PATH = '/public/rest/api/1.0/executions/export/download/' + fileName
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')
# REQUEST HEADER: to authenticate and authorize api
headers = {
'Authorization': 'JWT '+token,
'Content-Type': 'application/json',
'zapiAccessKey': ACCESS_KEY
}
cycle = {
'fileName': '0001677994347309-242ac113-0001'
}
# MAKE REQUEST:
raw_result = requests.get(BASE_URL + RELATIVE_PATH, headers=headers, json=cycle)
print(raw_result)