Call a web service - Post to get a bearer token

  • 17 June 2024
  • 6 replies

Badge +1


I need to Post to an API URL sending my username and password to get a bearer token returned. I’m struggling with the syntax needed to send form data plus these 2 inputs. I’ve used Postman to test my credentials and the URL. I get a 200 status code and the token is returned. However, I haven’t been able to get it to work within Nintex itself.

Can someone please tell me what belongs in the Request headers and Request content boxes to make this work?

Kind regards,




Best answer by bsikes 17 June 2024, 18:35

View original

6 replies

Userlevel 5
Badge +13

Hi @jennym 

The best method for doing this would be to build out an xtension to store the call procedure, then it can be added to both forms and workflows and Nintex will handle the token handshake for you.

Here is an example xtension which performs this using oauth2:



Userlevel 2
Badge +6

Hi @jennym 

I found the example code here useful to see what headers to send,


  request.setRequestHeader("Content-Type", "application/json");
  request.setRequestHeader("Authorization", `Bearer ${token}`);
Badge +1

Thanks, both. I appreciate the answers. For this instance though, I’d like the quick and easy answer on how to format form fields to send through the basic fields first, please. I don’t want to build an extension if all I’m trying to do is post a username and password to a URL and retrieve a token as the variable. I’ve hard-coded the token from Postman in my next call and gotten a 200. Can you please share the syntax to do this in the Request headers or Request content fields? Thanks

Userlevel 2
Badge +6

Hi @jennym 

What service are you calling against?  The configuration of Web Services is dependent on what API you’re calling so without what API you’re calling it’s not possible to know what configuration you’d need.

I’d also recommend looking at building an Xtension rather than using a pure web service buildout (I assume you’re calling another web service after this using the bearer token).  For the documentation on how to build out Xtensions you can look here:

Lastly you might want to check the Nintex Gallery to see if someone else has already built a connector to the service you're calling:{}&index=[]&currentPage=1

Userlevel 2
Badge +6

And Jake beat me to it 

Userlevel 4
Badge +10


If you’d like an example of a “Call a Web Service” action that retrieves a bearer token, here’s a screenshot of an action that utilizes the action to get a bearer token from Nintex.



The bearer token that’s produced is available to be parsed out in the TokenResponse variable.  Hopefully this, along with the nintex token api documentation (, will help you figure out the format of whatever fields your particular service is needing.