X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fclients%2FAsyncRestClient.java;h=b10cf2791d3d9a3ca378a3db6e8760c732865bd0;hb=refs%2Fchanges%2F68%2F2368%2F3;hp=25742176eb5ad86fce964488b5656e195a7089f8;hpb=ff56d2600d074ac0a4473c81b8193004a316c2f8;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java index 25742176..b10cf279 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/AsyncRestClient.java @@ -49,7 +49,19 @@ public class AsyncRestClient { return client.post() // .uri(uri) // .contentType(MediaType.APPLICATION_JSON) // - .syncBody(body) // + .bodyValue(body) // + .retrieve() // + .onStatus(HttpStatus::isError, + response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) // + .bodyToMono(String.class); + } + + public Mono postWithAuthHeader(String uri, String body, String username, String password) { + return client.post() // + .uri(uri) // + .headers(headers -> headers.setBasicAuth(username, password)) // + .contentType(MediaType.APPLICATION_JSON) // + .bodyValue(body) // .retrieve() // .onStatus(HttpStatus::isError, response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) // @@ -61,7 +73,7 @@ public class AsyncRestClient { return client.put() // .uri(uri) // .contentType(MediaType.APPLICATION_JSON) // - .syncBody(body) // + .bodyValue(body) // .retrieve() // .onStatus(HttpStatus::isError, response -> Mono.error(new AsyncRestClientException(response.statusCode().toString()))) //