Skip to main content
Nintex Community Menu Bar
Solved

Call a web service - Post to get a bearer token


Forum|alt.badge.img+1

Hello,

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,

Jenny

 

Best answer by bsikes

@jennym 

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 (https://developer.nintex.com/docs/nc-api-docs/1e26b9d25afd4-applications), will help you figure out the format of whatever fields your particular service is needing. 

View original
Translate
Did this topic help you find an answer to your question?

6 replies

Jake
Forum|alt.badge.img+13
  • Scholar
  • 319 replies
  • June 17, 2024

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.

 

https://help.nintex.com/en-US/xtensions/02_BuildOpenAPI/01_Basic/PRC_01Find_API.htm

Here is an example xtension which performs this using oauth2: 

https://gallery.nintex.com/t/linkedin

 

Jake 

Translate

Forum|alt.badge.img+8
  • Apprentice
  • 63 replies
  • June 17, 2024

Hi @jennym 

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

https://help.nintex.com/en-us/k2cloud/userguide/current/Content/Runtime/WF-REST-API/WF-REST-API-Authentication.htm

example,

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

Forum|alt.badge.img+1
  • Author
  • Rookie
  • 2 replies
  • June 17, 2024

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

Translate

Forum|alt.badge.img+9
  • Nintex Employee
  • 65 replies
  • June 17, 2024

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: https://help.nintex.com/en-US/xtensions/Home.htm

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: https://gallery.nintex.com/search?search_term=&capability=10005&industry=&department=&partner=&capabilities=connectors&sortBy=&aggregation={}&index=[]&currentPage=1

Translate

Forum|alt.badge.img+9
  • Nintex Employee
  • 65 replies
  • June 17, 2024

And Jake beat me to it 

Translate

Forum|alt.badge.img+10
  • Scout
  • 129 replies
  • Answer
  • June 17, 2024

@jennym 

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 (https://developer.nintex.com/docs/nc-api-docs/1e26b9d25afd4-applications), will help you figure out the format of whatever fields your particular service is needing. 

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings