I have to call post
api to generate token
using webclient
. I will send jwt
token in assertion
. I have got some example
through net but I dont know how to pass parameters like along with API. can someone help with the same?
I need to call docusign api https://account-d.docusign.com/oauth/token
also I need to send grant_type
and assertion
. I dont know how to receive this. can someone help with example? below is the image for reference.
CodePudding user response:
To build uri with query params you can use 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();
CodePudding user response:
If u are using java then you can use 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();
If u are using spring then you can go for webclient. U can set headers like this.
webClient.post()
.uri(UriComponentsBuilder.fromUriString("url").queryParam("assertion", "").queryParam("grant_type", "").toUriString()).retrieve();
Hope this helps you to set multiple headers.