UPC_Broadband_L
11 years agoOccasional Contributor
[Resolved] JSON conversion to XML does not work
Hi,
Right now, I'm using a REST api for a Jira plugin, Zephyr (here's the documentation for reference [though not necessary for this issue]: http://docs.getzephyr.apiary.io/).
They all return JSON responses. SoapUI seems to automatically convert these to XML so they can be edited / processed.
However, one of them returns this:
Apparently soapUI's automatic JSON to XML conversion fails.
It returns this: <xml/>
Ergo, I can't manipulate it, transfer properties, etc.
Trying to use a groovy script to retrieve only the JSON as a string always returns the "<xml/>" response. Ex:
- def response = context.expand( '${name#Response}' ).toString()
- responseContent = testRunner.testCase.getTestStepByName("name").getPropertyValue("response")
ResponseAsXml does not work in this case, since the XML was not properly converted.
- Note: The error returned is "NCNames cannot start with the character 2d", probably because one of the elements starts with a number and that does not follow XML conventions.
Is there a way to:
1- Fix the response so it's "XML convertible" JSON?
or
2- Fetch the response as JSON only, not wrongly converted XML, so that it can be slurped?
Right now, I'm using a REST api for a Jira plugin, Zephyr (here's the documentation for reference [though not necessary for this issue]: http://docs.getzephyr.apiary.io/).
They all return JSON responses. SoapUI seems to automatically convert these to XML so they can be edited / processed.
However, one of them returns this:
{
"status": {
"1": {
"id": 1,
"color": "#75B000",
"description": "Test was executed and passed successfully.",
"name": "PASSED"
},
"2": {
"id": 2,
"color": "#CC3300",
"description": "Test was executed and failed.",
"name": "FAILED"
},
"3": {
"id": 3,
"color": "#ffff00",
"description": "Test is Not tested in this cycle.",
"name": "NOT TESTED"
},
"4": {
"id": 4,
"color": "#6693B0",
"description": "The test execution of this test was suspended.",
"name": "TEST SUSPENDED"
},
"6": {
"id": 6,
"color": "#ff9900",
"description": "Test is failed, but not a high priority issue",
"name": "ACCEPTED FAILED"
},
"-1": {
"id": -1,
"color": "#bbbbbb",
"description": "The test has not yet been executed.",
"name": "SCHEDULED"
}
},
"issueId": 1234,
"executions": [ {
"id": 1234,
"executionStatus": "-1",
"comment": "",
"htmlComment": "",
"cycleId": 1234,
"cycleName": "Cycle Name 2014-06-05",
"versionId": 1234,
"versionName": "version",
"projectId": 1234,
"issueId": 1234,
"issueKey": "TEST-1234",
"summary": "Summary Sample 1",
"issueDescription": "<p><p><span style=\"color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;\">test & test.</span></p><\/p>",
"label": "TEST, TEST2",
"component": "TEST",
"projectKey": "TEST"
}],
"currentlySelectedExecutionId": "",
"recordsCount": 1
}
Apparently soapUI's automatic JSON to XML conversion fails.
It returns this: <xml/>
Ergo, I can't manipulate it, transfer properties, etc.
Trying to use a groovy script to retrieve only the JSON as a string always returns the "<xml/>" response. Ex:
- def response = context.expand( '${name#Response}' ).toString()
- responseContent = testRunner.testCase.getTestStepByName("name").getPropertyValue("response")
ResponseAsXml does not work in this case, since the XML was not properly converted.
- Note: The error returned is "NCNames cannot start with the character 2d", probably because one of the elements starts with a number and that does not follow XML conventions.
Is there a way to:
1- Fix the response so it's "XML convertible" JSON?
or
2- Fetch the response as JSON only, not wrongly converted XML, so that it can be slurped?