Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
let StringClass = Java.type("java.lang.String");
let responseString = webClient.get().uri("https://host.com/some-uri")
                .retrieve()
                .bodyToMono(StringClass)
                .block();

To include a body, the most simple way would be to use .bodyValue()so it would look like this:

Code Block
languagejs
let requestBody = ... //body value
let responseString = webClient.post()
                .uri("https://host.com/path/to/resource")
                .bodyValue(requestBody)
                .retrieve()
                .bodyToMono(StringClass)
                .block();

JSON Parsing Example

It is recommended to select String as the return type and then parse the JSON in JavaScript. Here’s how you can parse a JSON response:

...