JSON Parse Exception Unexpected character

I am trying to connect neo4j with DesiteMd through javascrift. But in neo4j i am getting the following message ''WARN /db/data/cypher org.codehaus.jackson.JsonParseException: Unexpected character ('o' (code 111)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: java.io.StringReader@3eb74e5; line: 1, column: 3]' The javascrift which I am using is

function myFunction5() {
var x = desiteAPI.getSelected(); 


        document.getElementById("demo").innerHTML = String(x);

        var myJSON = JSON.stringify ("x");

        var MatchQuery = new XMLHttpRequest();
        MatchQuery.open('POST', 'http://localhost:7474/db/data/cypher ', true);
        MatchQuery.setRequestHeader("Content-type", "application/json;charset=utf-8");//"Basic " + btoa("neo4j:123")

        var y = {"query" : "MATCH(a:" + String(x) + "), (b:Tasks) MERGE(a)-[r:relation]-(b) Return a,b"};


        MatchQuery.addEventListener('load', function (event) {
            if (MatchQuery.status >= 200 && MatchQuery.status < 300) {

            } else {
                console.warn(MatchQuery.statusText, MatchQuery.responseText);

Could somebody guide me kindly? Thank you

There are several things in this code you need to check and possibly fix.

  1. In your cypher endpoint, you have an extra space at the end of the HTTP endpoint URL which is incorrect
  2. JSON.stringify("x") probably doesn't do what you intend - that will just return the string "x" because you're passing it a literal and not a variable. I'm not even sure you're using myJSON
  3. When you construct your cypher query with this: "MATCH(a:" + String(x) + ") I'm not sure the right thing is happening there either, and I can't see the value of the variable X. So the root cause is probably that you're constructing an invalid JSON object in 'y'.

Make sure that 'y' is valid JSON first.