Chilenny
4 months agoNew Contributor
Create Execution Failing
The following Create Execution is returning an 400 error. Is the URL correct?
POST https://prod-api.zephyr4jiracloud.com/connect/public/rest/api/1.0/execution
400
{"error":"API not found."}
Code:
// Get issueId via method getIssueId()
public Integer createExecution(int status, String cycleId, String projectId, String versionId, String issueId,
String assignee) throws Exception {
int executionId = 0;
String baseUrl = "https://prod-api.zephyr4jiracloud.com/connect";
String url = "https://prod-api.zephyr4jiracloud.com/connect/public/rest/api/1.0/execution";
ZFJCloudRestClient client2 = ZFJCloudRestClient.restBuilder(baseUrl, accessKey, secretKey, accountId).build();
JwtGenerator jwtGenerator = client2.getJwtGenerator();
URI uri = new URI(url);
int expirationInSec = 360;
String jwt = jwtGenerator.generateJWT("POST", uri, expirationInSec);
System.out.println(jwt);
JSONObject statusTestsObj = new JSONObject();
statusTestsObj.put("id", 1);
JSONObject executeTestsObj = new JSONObject();
executeTestsObj.put("status", statusTestsObj);
executeTestsObj.put("id", "d7d2c6d3-995d-4933-8c92-8b445965be6f");
executeTestsObj.put("projectId", 10036);
executeTestsObj.put("issueId", 842906);
executeTestsObj.put("versionId", -1);
StringEntity addTestsJSON = null;
addTestsJSON = new StringEntity(executeTestsObj.toString());
HttpResponse response = null;
HttpClient restClient = new DefaultHttpClient();
HttpPut updateTest = new HttpPut(uri);
updateTest.setHeader("Content-Type", "application/json");
updateTest.setHeader("Authorization", jwt);
updateTest.setHeader("zapiAccessKey", accessKey);
updateTest.setEntity(addTestsJSON);
try {
response = restClient.execute(updateTest);
} catch (ClientProtocolException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
int statusCode = response.getStatusLine().getStatusCode();
System.out.println(statusCode);
}