Hello, I have this curl request:
curl -H Content-Type:text/xml -X POST -H "Authorization: Bearer MY_TOKEN" --data @/path/to/JUnit_Report.xml https://host/api/v1/import/execution/junit?projectKey=XXX
It will at the end export tests results to Jira. In bbash I don’t have any issue with this request.
I tried to do send it with Katalon in script mode, but didn’t succeed…
This is what I have done: (several methods)
First method:
ProcessBuilder pb2 = new ProcessBuilder(
"curl", "-H", "Content-Type:text/xml", "-H", "\"Authorization: Bearer " + MY_TOKEN + "\"", "-X", "POST", "--data",
"@/path/to/JUnit_Report.xml",
"https://host/api/v1/import/execution/junit?projectKey=XXX"
);
pb2.redirectErrorStream(true);
Process p2 = pb2.start();
Curl request seems to not fail, but no data are exported to Jira.
Second method:
TestObjectProperty auth = new TestObjectProperty()
auth.setName("Authorization")
auth.setValue("Bearer " + token)
TestObjectProperty content = new TestObjectProperty()
content.setName("Content-Type")
content.setValue("text/xml")
def headers = new ArrayList()
headers.add(auth)
headers.add(content)
TestObjectProperty param = new TestObjectProperty()
param.setName("--data")
param.setValue("@/path/to/JUnit_Report.xml")
def params = new ArrayList()
params.add(param)
RequestObject reqObj = new RequestObject()
reqObj.setHttpHeaderProperties(headers)
reqObj.setRestRequestMethod('POST')
reqObj.setRestUrl('https://host/api/v1/import/execution/junit?projectKey=XXX')
reqObj.setRestParameters(params)
def getResponse = WSBuiltInKeywords.sendRequest(reqObj)
This didn’t work (NPE) but I don’t even know if it is correctly implemented. Documentation does not help.
Is there someone who has an idea?
Thanks