I am consuming an API and this one in particular response with nothing but status code 201 in postman. In my code, how do I extract the status code using WebClient?
public HttpStatus createUser(String uuid) throws Exception {
MultiValueMap<String, String> bodyValues = new LinkedMultiValueMap<>();
bodyValues.add("providerCallbackHost", "https://webhook.site/c6c0a388-2af5-41e1-8d6d-c280820affad");
try {
HttpStatus response = webClient.post()
.uri("https://sandbox.momodeveloper.mtn.com/v1_0/apiuser")
.header("X-Reference-Id", uuid)
.header("Ocp-Apim-Subscription-Key", SUBSCRIPTION_KEY_SECONDARY)
.contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(bodyValues))
.retrieve()
.bodyToMono(HttpStatus.class)
.block();
return response;
} catch (Exception exception) {
throw new Exception(exception.getMessage());
}
}