Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Convert XML file to json


#1

Hi!
I just try to integrate our automation testing tool with TestRail. I`m using curl to read the api.
The problem is that I get the results in a XML file. I have to convert it into json.

After converting it looks like this:

Command:
curl --insecure -H “Content-Type: application/xml” -u “xx xxx” -d “@D:\worksoft\curl\TRgetCase.xml” “https://10.241.4.15/testrail-staging/index.php?/api/v2/add_result/1421

Error message: “Invalid or incomplete JSON string in API request”

Maybe someone can help me.

Thanks!


#2

Yea - that is not JSON which is a match pair like this:
{
“id”: 1,
“name”: “A green door”,
“price”: 12.50,
“tags”: [“home”, “green”]
}

it does not have a xml ‘header’ or anything with < >.

Wonder if yo use a site like this if it will correctly convert XML to appropriate json:


#3

Hi @Travelstar,

JSON and XML are two completely different formats/protocols and you can find working examples on how to use TestRail’s API here:

http://docs.gurock.com/testrail-api2/accessing

You can also use one of the API bindings to access the API directly from .NET, Java, etc.

Do you use the XML exports to extract data from TestRail? You can also use TestRail’s API for this instead and this would already be in JSON format (or the equivalent data structure if you use an API binding).

I hope this helps!

Cheers,
Tobias