Getcookies function for POST REST message that goes through the MID server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 12:01 PM - edited 11-20-2024 05:39 AM
Hello,
For an integration that was requested, we need to make a REST call to an application where we provide the necessary information to the endpoint which essentially logs in and should provide a session_id back that is then used in a "get" request.
When I do it through Postman, I am able to see the session_id returned in the desktop client. If I use that session_id in my "get" message I am able to get the data from the other system.
I have tried all the articles I can find related to getting cookies from the response but it is either showing as empty, null or undefined. The REST is currently going through the MID server and in the ecc queue I see an input that has data in it with a session_id but the ID looks to be an internal ServiceNow session_id and not the session_id from the website.
Does anyone know if there is something extra needed to have cookies work in ServiceNow the same way they do on Postman when using the MID server? Are there specific headers or other entries needed for it to allow cookies?
UPDATE: I was able to get this to work through the MID server after working through a session with the team that owns the site and another person on my team. The issue was that even though a 200 response was returned it was not truly logging into the app. We tried several formats and the following is the format that the system liked and allowed the call to "log in" and get the session ID. Other headers like Content-Type for "application/x-www-form-urlencoded" were in the rest message area.