How to get the original response

Here’s an answer in return for your answer on REST API example :relaxed:

This just shows you the actual message, properly decoded.

var strServerResponse = "{"errors":[{"errorMessage":"Device ID inv\\u00e1lido"}]}";

function rhtmlspecialchars(str) {
    // Remove HTML Special characters first
    if (typeof(str) == "string") {
        str = str.replace(/>/ig, ">");
        str = str.replace(/&lt;/ig, "<");
        str = str.replace(/&#039;/g, "'");
        str = str.replace(/&quot;/ig, '"');
        str = str.replace(/&amp;/ig, '&'); /* must do &amp; last */
    }
    return str;
}

// First remove the html special characters
var strServerResponseWOspecialChars = rhtmlspecialchars(strServerResponse);

// Use JSON parse to turn it into a JSON Object
var jsonObj = JSON.parse(strServerResponseWOspecialChars);

// Now easily pull out the stuff we need from this object

    alert(jsonObj.errors[0].errorMessage); // assuming that the message is in this format "{'errors':[{'errorMessage':'Device ID inválido'}]}"

Cheers,
M.M