Skip to main content
Formatted, few grammar fixes too
Source Link
Stphane
  • 3.4k
  • 5
  • 34
  • 47

If response of below request is in xmlXML format,

pm.sendRequest({
    url: myUrl,
    method: 'GET',
    header: {
        'content-type': 'application/json'
    }
}, function (err, res) {
    console.log(res)
});

I am trying to convert response using below var jsonObject = xml2Json(res); it code

var jsonObject = xml2Json(res);

It is giving error saying JSONError | Unexpected token u in JSON at position 0

JSONError | Unexpected token u in JSON at position 0

When I used that same function with testscript  , It is converting xmlXML to hsonObject var jsonObject = xml2Json(responseBody);

var jsonObject = xml2Json(responseBody);

If response of below request is in xml format,

pm.sendRequest({
    url: myUrl,
    method: 'GET',
    header: {
        'content-type': 'application/json'
    }
}, function (err, res) {
    console.log(res)
});

I am trying to convert response using below var jsonObject = xml2Json(res); it is giving error saying JSONError | Unexpected token u in JSON at position 0

When I used same function with testscript  , It is converting xml to hsonObject var jsonObject = xml2Json(responseBody);

If response of below request is in XML format,

pm.sendRequest({
    url: myUrl,
    method: 'GET',
    header: {
        'content-type': 'application/json'
    }
}, function (err, res) {
    console.log(res)
});

I am trying to convert response using below code

var jsonObject = xml2Json(res);

It is giving error saying

JSONError | Unexpected token u in JSON at position 0

When I used that same function with testscript, It is converting XML to hsonObject

var jsonObject = xml2Json(responseBody);
Source Link

If response of below request is in xml format,

pm.sendRequest({
    url: myUrl,
    method: 'GET',
    header: {
        'content-type': 'application/json'
    }
}, function (err, res) {
    console.log(res)
});

I am trying to convert response using below var jsonObject = xml2Json(res); it is giving error saying JSONError | Unexpected token u in JSON at position 0

When I used same function with testscript , It is converting xml to hsonObject var jsonObject = xml2Json(responseBody);