- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 05:29 AM
Hello,
I have a SOAP integration setup and all works well. My issue is, I am trying to pass Basic Auth credentials to the envelope. How can I do this?
Also, I would like to use basic auth credentials via script when making this reference in a flow I have configured.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2024 06:41 AM
To pull the password from the basic auth profile instead of hardcoding it, you can use the setAuthenticationProfile method instead of setBasicAuth. Here's how you can do it:
- First, ensure that you have an authentication profile set up in ServiceNow. You can do this by navigating to System Web Services > Outbound > Basic Auth Profile.
- Create a new record and fill in the necessary details such as Name, Username, and Password.
- Once the profile is set up, you can use the setAuthenticationProfile method in your script. Here's an example:
javascript
try {
var s = new sn_ws.SOAPMessageV2('DAM', 'login');
// Use authentication profile
s.setAuthenticationProfile('basic', 'your_auth_profile_name'); // 'your_auth_profile_name' is the name of the basic auth profile you created
var response = s.execute();
var responseBody = response.getBody();
var status = response.getStatusCode();
} catch(ex) {
var message = ex.message;
}
In summary:
- Create a Basic Auth Profile in ServiceNow with the required credentials.
- Use the setAuthenticationProfile method in your script, passing 'basic' as the first argument and the name of your auth profile as the second argument.
- This method will automatically use the username and password from the specified auth profile, eliminating the need to hardcode these values in your script.
nowKB.com
For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/
For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 06:39 AM
@mballinger You can use setBasicAuth(String userName, String userPass) method to set the credentials on the SOAP envelope.
For more information, please refer to https://developer.servicenow.com/dev.do#!/reference/api/vancouver/server/sn_ws-namespace/c_SOAPMessa...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 07:26 AM
@Sandeep Rajput Thank you for your response! My issue is the vendor I am trying to hit needs a username password to be passed.