POST-Anfrage im Webclient, um einen Anfragetext in JSON hinzuzufügenJava

Java-Forum
Anonymous
 POST-Anfrage im Webclient, um einen Anfragetext in JSON hinzuzufügen

Post by Anonymous »

Ich versuche, eine API-POST-Anfrage mit WebClient in Spring Boot zu stellen. Ich kann jedoch nicht wie gewünscht eine Anfrage mit dem JSON-Text stellen und die Antwort als JSONObject erhalten.
JSON BODY :

Code: Select all

{
"workspaces": [
"6eret123",
"b129078v",
"ngy66553",
"erfc1153"
]
}
Dienstklasse-

Code: Select all

Workspaces workspace = new Workspaces(mw);
Flux modifiedWorkspace =
webClient.post()
.uri(URIDetails.MODIFIEDWORKSPACE)
.header("Authorization", bearerToken)
.body(Mono.just(mw), Workspaces.class)
.retrieve()
.bodyToFlux(Workspaces.class);
modifiedWorkspace.doOnNext(System.out::println).blockLast();
return null;
Workspaces-Modell-

Code: Select all

public class Workspaces {
private List workspaces;
}
Hauptanruf-

Code: Select all

Flux modifiedWorkspaces;
final List mw = new ArrayList();
for (Workspace w : modifiedWorkspaces) {
mw.add(w.getId());
}
modifiedWorkspaces = scanRespone(mw);
Ich muss eine Liste der JSON-Bodys senden, die als Body-Post-Anfrage erwähnt werden.
Bitte helfen Sie mir bei der Post-Anfrage
Vielen Dank im Voraus

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post