我必须调用post api来使用webclient生成token。我将在jwt中发送assertion令牌。我有一些example通过网络,但我不知道如何传递参数,如与API。有人能帮上忙吗?
我需要打电话给docusign https://account-d.docusign.com/oauth/token
另外,我还需要发送grant_type和assertion。我不知道怎么收到这个。有人能帮忙举个例子吗?下面是供参考的图片。
发布于 2022-06-20 14:47:15
若要使用查询参数生成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();发布于 2022-06-20 15:01:58
如果您使用的是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://stackoverflow.com/questions/72688741
复制相似问题