Hello,
I´m trying to run this matrix example provided on the documentation in Java (here):
Client client = ClientBuilder.newClient();
Entity<String> payload = Entity.json({"locations":[[9.70093,48.477473],[9.207916,49.153868],[37.573242,55.801281],[115.663757,38.106467]]});
Response response = client.target("https://api.openrouteservice.org/v2/matrix/driving-car")
.request()
.header("Authorization", "api_key")
.header("Accept", "application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8")
.header("Content-Type", "application/json; charset=utf-8")
.post(payload);
System.out.println("status: " + response.getStatus());
System.out.println("headers: " + response.getHeaders());
System.out.println("body:" + response.readEntity(String.class));
However I’m getting an error on this line: Entity<String> payload = Entity.json({"locations":[[9.70093,48.477473],[9.207916,49.153868],[37.573242,55.801281],[115.663757,38.106467]]});
The error is this one:
Multiple markers at this line
- Syntax error, insert “;” to complete
LocalVariableDeclarationStatement
- The method json(T) in the type Entity is not applicable for the
arguments ()
- Syntax error on tokens, delete these tokens
- Syntax error, insert “)” to complete MethodInvocation
Since this is a straight up copy from the documentation and I’m relatively new to this matter, does anyone know how to solve it ?
Thanks