- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 06:38 AM
I am using an API call to Authenticate and receiving the below xml response:
<results probe_time="4590" result_code="0">
<result>
<output>{"status":"Success","messages":[],"data":{"sessionId":"dd77a6db7e4bfdc220e1527cf09d15c9","faSessionId":"kmoaj6s402g8qpp4rlo2rfl3c2","phpSessionId":"kmoaj6s402g8qpp4rlo2rfl3c2"}}</output>
</result>
<httpCookies>
<httpCookie value="FireFlow_Session=dd77a6db7e4bfdc220e1527cf09d15c9; Path=/aff/api/external; Secure; HttpOnly; SameSite=Lax"/>
</httpCookies>
Trying to get that httpCookie value for just the "FireFlow_Session" so that I can add it into my next run script API call to pass variables from SNOW to FireFlow.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 08:06 AM - edited 03-20-2025 08:07 AM
Hello @booher04
1. Always a challenge or takes longer than usual to parse XML, so better convert xml to json as mentioned here: https://www.servicenow.com/community/developer-forum/unable-to-iterate-through-xml-response-and-and-...
2. If you can save the xml response in a variable, then it will be easy to capture it as shown below:
var responseBody = `<results probe_time="4590" result_code="0"><result><output>{"status":"Success","messages":[],"data":{"sessionId":"dd77a6db7e4bfdc220e1527cf09d15c9","faSessionId":"kmoaj6s402g8qpp4rlo2rfl3c2","phpSessionId":"kmoaj6s402g8qpp4rlo2rfl3c2"}}</output></result><httpCookies><httpCookie value="FireFlow_Session=dd77a6db7e4bfdc220e1527cf09d15c9; Path=/aff/api/external; Secure; HttpOnly; SameSite=Lax"/></httpCookies>`;
var match = responseBody.match(/FireFlow_Session=([^;]+)/);
var fireFlowSession = match ? match[1] : '';
gs.info("Extracted FireFlow_Session: " + fireFlowSession);
Please share your results here so that we all can learn together.
Hope that helps!
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 08:06 AM - edited 03-20-2025 08:07 AM
Hello @booher04
1. Always a challenge or takes longer than usual to parse XML, so better convert xml to json as mentioned here: https://www.servicenow.com/community/developer-forum/unable-to-iterate-through-xml-response-and-and-...
2. If you can save the xml response in a variable, then it will be easy to capture it as shown below:
var responseBody = `<results probe_time="4590" result_code="0"><result><output>{"status":"Success","messages":[],"data":{"sessionId":"dd77a6db7e4bfdc220e1527cf09d15c9","faSessionId":"kmoaj6s402g8qpp4rlo2rfl3c2","phpSessionId":"kmoaj6s402g8qpp4rlo2rfl3c2"}}</output></result><httpCookies><httpCookie value="FireFlow_Session=dd77a6db7e4bfdc220e1527cf09d15c9; Path=/aff/api/external; Secure; HttpOnly; SameSite=Lax"/></httpCookies>`;
var match = responseBody.match(/FireFlow_Session=([^;]+)/);
var fireFlowSession = match ? match[1] : '';
gs.info("Extracted FireFlow_Session: " + fireFlowSession);
Please share your results here so that we all can learn together.
Hope that helps!
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 08:29 AM
convert that to json and then parse
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader