Need remote address/IP from a scoped Scripted REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2026 10:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2026 11:11 AM
You can try with it:
gs.log("IP address: " + request.headers["x-forwarded-for"], "HEADERS");
OR
var reqHeader = request.headers;
var jsonObj = new JSON();
var headerStr = jsonObj.encode(reqHeader);
gs.log('headers'+headerStr);
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2026 06:38 PM
What are you doing with the ip? If it's for whitelisting you could use rest api access policies.
Unauthenticated transactions will still have a jsessionid and will just use the guest user as a proxy. You can get the session id in a scoped script with gs.getSessionID(). With the sessionid it should be trivial to get the ip from the transaction log but the transaction is not logged before the transaction is finished. Maybe it's possible on the fly from somewhere else.