我必須呼叫postapi 來生成token使用webclient. 我將發送jwt令牌assertion。我有一些example通過網路,但我不知道如何傳遞引數,比如 API。有人可以幫忙嗎?
我需要呼叫docusign apihttps://account-d.docusign.com/oauth/token
我還需要發送grant_type和assertion。我不知道如何接收這個。有人可以舉個例子嗎?下面是圖片供參考。
在此處輸入影像描述
uj5u.com熱心網友回復:
要使用查詢引數構建 uri,您可以使用UriComponentsBuilder
final WebClient.ResponseSpec response = webClient.post()
.uri(UriComponentsBuilder.fromUriString("https://account-d.docusign.com/oauth/token")
.queryParam("grant_type", "xyz")
.queryParam("assertion", "anything")
.toUriString())
.retrieve();
uj5u.com熱心網友回復:
如果您使用的是 java,那么您可以使用 HTTPClient。
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("url"))
.headers("Content-Type", "text/plain;charset=UTF-8")
.headers("grant_type", "")
.headers("assertion", "")
.POST(HttpRequest.BodyPublishers.ofString("Sample request body"))
.build();
如果您使用的是spring,那么您可以使用webclient。你可以像這樣設定標題。
webClient.post()
.uri(UriComponentsBuilder.fromUriString("url").queryParam("assertion", "").queryParam("grant_type", "").toUriString()).retrieve();
希望這可以幫助您設定多個標題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/494897.html
上一篇:Spring多個非產品環境屬性
