diff --git a/src/tech/avroid/api/Eva.groovy b/src/tech/avroid/api/Eva.groovy index 7654b47..6008a1d 100644 --- a/src/tech/avroid/api/Eva.groovy +++ b/src/tech/avroid/api/Eva.groovy @@ -23,13 +23,12 @@ class Eva implements Serializable { /** * Create new link for Eva Object. For example, tasks - * !WARNING: can to create multiple similar links + * !WARNING: can to create multiple similar links * @param parentId String - id of Object for which created link * @param linkName String - name of link * @param url String - full url of link - * @return Boolean - success or failure create */ - public createLink(String parentId, String linkName, String url) { + public void createLink(String parentId, String linkName, String url) { Map body = [ jsonrpc: "1.2", method: "CmfLink.create", @@ -41,13 +40,13 @@ class Eva implements Serializable { script.withCredentials([script.string(credentialsId: creds, variable: 'token')]) { script.httpRequest( - url: "$host/api/", - contentType: 'APPLICATION_JSON', - httpMode: 'POST', - customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]], - validResponseCodes: '200', - requestBody: JsonOutput.toJson(body) - ) + url: "$host/api/", + contentType: 'APPLICATION_JSON', + httpMode: 'POST', + customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]], + validResponseCodes: '200', + requestBody: JsonOutput.toJson(body) + ) } } @@ -59,8 +58,12 @@ class Eva implements Serializable { */ public String getTaskId(String filterValue, String filterParam = "code") { String response = getTask(filterValue, filterParam) + Object result = new JsonSlurper().parseText(response).result - return new JsonSlurper().parseText(response).result.id + if (result) { + return result.id + } + return null } /** @@ -83,7 +86,7 @@ class Eva implements Serializable { contentType: 'APPLICATION_JSON', httpMode: 'POST', customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]], - validResponseCodes: '200', + validResponseCodes: '200', requestBody: JsonOutput.toJson(body) ).content.toString() }