Mutate multiline string

I am trying to add a multiline string into the database but I cannot seem to find a way how to do it.

I tried using ``

{
  set {
    _:ms <MultilineString> `
    				This is 
    				a multiline string
    						` .
  }
}

error:

{
  "name": "t",
  "url": "http://localhost:8080/mutate?commitNow=true",
  "errors": [
    {
      "message": "while lexing _:ms <MultilineString> ` at line 1 column 22: Invalid input: ` at lexText",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ]
}

With " "

{
  set {
    _:ms <MultilineString> "
    				This is 
    				a multiline string
    						" .
  }
}
{
  "name": "t",
  "url": "http://localhost:8080/mutate?commitNow=true",
  "errors": [
    {
      "message": "while unquoting: invalid syntax",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ]
}

How am I able to store a multiline text?

Dgraph’s parser doesn’t supports multiline. You have to use JSON escaping on your end.

Ok thanks,

In the meantime I am escaping the \n in c# and it works for me.

@" 
    	This is 
    	a multiline string
".Replace(Environment.NewLine, "\\n");

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.