0

I want to use Rest Assured to work with Azure DevOps. All was smooth until it came to creating testcases. I am able to create it with hardcoded strings. This is not as useful because I'll need to port the strings as POJO objects for reusability. I tried this on Postman, and it works perfectly. I have tried to, first of all, change the XML string to JSON but always get the error of unformatted HTML.

This is the payload in Postman

{
        "op": "add",
        "path": "/fields/Microsoft.VSTS.TCM.Steps",
        "value": "<steps id=\"0\" last=\"1\"><step id=\"2\" type=\"ValidateStep\"><parameterizedString isformatted=\"true\">Input step 1</parameterizedString><parameterizedString isformatted=\"true\">Expectation step 1</parameterizedString><description/></step><step id=\"2\" type=\"ValidateStep\"><parameterizedString isformatted=\"true\">Input step 1</parameterizedString><parameterizedString isformatted=\"true\">Expectation step 1</parameterizedString><description/></step><step id=\"2\" type=\"ValidateStep\"><parameterizedString isformatted=\"true\">Input step 1</parameterizedString><parameterizedString isformatted=\"true\">Expectation step 1</parameterizedString><description/></step></steps>"
    }

How do I port this to JSON? I mean the values of the value attribute.

This is the ported version to JSON to be used in Postman.

[
    {
        "op": "add",
        "path": "/fields/System.Title",
        "from": null,
        "value": "new addition step apps new definition"
    },
    {
        "op": "add",
        "path": "/fields/Microsoft.VSTS.TCM.Steps",
        "value": {
            "id": "0",
            "last": "1",
            "steps": [
                {
                    "id": "2",
                    "type": "ValidateStep",
                    "parameterizedString": [
                        {
                            "isformatted": "true",
                            "value": "Input step 1"
                        },
                        {
                            "isformatted": "true",
                            "value": "Expectation step 1"
                        }
                    ],
                    "description": ""
                },
                {
                    "id": "2",
                    "type": "ValidateStep",
                    "parameterizedString": [
                        {
                            "isformatted": "true",
                            "value": "Input step 1"
                        },
                        {
                            "isformatted": "true",
                            "value": "Expectation step 1"
                        }
                    ],
                    "description": ""
                },
                {
                    "id": "2",
                    "type": "ValidateStep",
                    "parameterizedString": [
                        {
                            "isformatted": "true",
                            "value": "Input step 1"
                        },
                        {
                            "isformatted": "true",
                            "value": "Expectation step 1"
                        }
                    ],
                    "description": ""
                }
            ]
        }
    }
]

When the ported JSON is run in Postman, it returns this error. But if I use the String format above, it works perfectly. I'll need to port the values of the value parameter to JSON so that I can create POJO classes from them.

ken4ward
  • 2,246
  • 5
  • 49
  • 89
  • I don't know what you mean by "ported", but the reason it's not working is because the API isn't expecting a JSON object, it's expecting JSON expressed as a string. You can see that clearly in your first example, the entire JSON payload is enclosed in double quotes and has quotes escaped. – Daniel Mann May 10 '23 at 03:11

0 Answers0