Feels like JSON mutation is broken

Moved from GitHub ratel/88

Posted by MichelDiz:

Tested in master and Dgraph’s master.

{
  "set": [
    {
      "name": "Alice"
    },
    {
      "name": "Bob"
    }
  ]
}

paulftw commented :

Does the same mutation work with curl? I recall there were syntax changes in 1.1

danielmai commented :

The same mutation works with curl.

$ curl -H Content-Type:application/json localhost:8180/mutate?commitNow=true -d '{
  "set": [
    {
      "name": "Alice"
    },
    {
      "name": "Bob"
    }
  ]
}'
{"data":{"code":"Success","message":"Done","uids":{"blank-0":"0x9ee70","blank-1":"0x9ee71"}},"extensions":{"server_latency":{"parsing_ns":31926,"processing_ns":19050004},"txn":{"start_ts":3089,"commit_ts":3090,"preds":["1-name"]}}}

Ratel is setting the header Content-Type: application/rdf even for JSON mutations. It should be Content-Type: application/json.

Here’s the result when running with application/rdf which matches the error shown in @MichelDiz’s screenshot.

$ curl -H Content-Type:application/rdf localhost:8180/mutate?commitNow=true -d '{
  "set": [
    {
      "name": "Alice"
    },
    {
      "name": "Bob"
    }
  ]
}'
{"errors":[{"code":"ErrorInvalidRequest","message":"while lexing {\n  \"set\": [\n    {\n      \"name\": \"Alice\"\n    },\n    {\n      \"name\": \"Bob\"\n    }\n  ]\n} at line 2 column 2: Unrecognized character inside mutation: U+0022 '\"'"}]}```

paulftw commented :

Fixed in 1678040