diff --git a/vars/drafter.groovy b/vars/drafter.groovy index 964b2ef..00d4b26 100644 --- a/vars/drafter.groovy +++ b/vars/drafter.groovy @@ -55,12 +55,17 @@ } } -def addData(String baseUrl, String credentials, String id, data, String type) { +def addData(String baseUrl, String credentials, String id, data, String type, String graph=null) { echo "Adding data to draftset ${id}" + String url = "${baseUrl}/v1/draftset/${id}/data" + if (graph) { + String encGraph = java.net.URLEncoder.encode(graph, "UTF-8") + url = url + "?graph=${encGraph}" + } def response = httpRequest(acceptType: 'APPLICATION_JSON', authentication: credentials, httpMode: 'PUT', - url: "${baseUrl}/v1/draftset/${id}/data", + url: url, requestBody: data, customHeaders: [[name: 'Content-Type', value: type]])