How to use javaclient excute delete edge

Example:
{
delete {
<0x1> <_follows> <0x2> .
}
}
use DgraphClient excute

I invoke as follows

@Test
public void deleteEdge(){
	String operatJson =
			"\t{\n" +
			"\t\tdelete {\n" +
			"\t\t\t<0x1>  <follows>  <0x2> .\n" +
			"\t\t}\n" +
			"\t}";

	DgraphProto.Mutation mutation = DgraphProto.Mutation.newBuilder()
			.setDeleteJson(ByteString.copyFromUtf8(operatJson)).build();
	Transaction txn = dgraphClient.newTransaction();
	txn.mutate(mutation);
	txn.commit();
}

but it throw Exception
Caused by: java.util.concurrent.ExecutionException: io.grpc.StatusRuntimeException: UNKNOWN: invalid character ‘d’ looking for beginning of object key string
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at io.dgraph.DgraphAsyncClient.lambda$runWithRetries$2(DgraphAsyncClient.java:180)
… 7 more

You are mixing NQuads with Json. As you are using setDeleteJson, following should work for your usecase:

String json = 
"{" +
"  \"uid\": \"0x1\"," +
"  \"follows\": \"0x2\"" +
"}";
DgraphProto.Mutation mutation = DgraphProto.Mutation.newBuilder()
			.setDeleteJson(ByteString.copyFromUtf8(json)).build();

OR
you could use NQuads for deletion as follows:

String nquadStr = "<0x1> <follows> <0x2> .";
DgraphProto.Mutation mutation = DgraphProto.Mutation.newBuilder()
			.setDelNquads(ByteString.copyFromUtf8(nquadStr)).build();

Notice the use of setDelNquads and setDeleteJson.

You can refer the the doc on Deletion using NQuads and following doc on Deletion using Json.

Thank you very much for the solution, but Json is still wrong. The correct Json is as follows
String operatJson =
“{\n” +
" "follows": {\n" +
" "uid": "0x7623"\n" +
" },\n" +
" "uid": "0x7622"\n" +
“}”;

Yeah! missed that.
Glad it worked!