Attachment api download link is redirecting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
if i enter user id and password here again this dialogue box comes up why is that ? this is by the refrence of attachment api metadata link where we get the attachment link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @sasharma815,
That's expected, and technically not a redirect: the download_link from the Attachment API is a plain instance URL, not a signed or token link. So the file endpoint needs the same authentication as any other instance request. Open it in a browser tab with no active session and you get a basic auth challenge instead, that's the native "Sign in" box you're seeing.
- Same browser, already logged into the instance: the link opens fine, no prompt.
- Script or integration calling it: pass an OAuth token or basic auth credentials in the Authorization header.
- Surfacing it through Virtual Agent to end users: use the Attachment output component in VA Designer instead of the raw download_link, it handles the authenticated fetch for you.
Thank you,
Vikram Karety
Octigo Solutions INC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @sasharma815
It is expected behavior.
The login dialog box reappears because the REST Attachment API requires authentication for each individual request. When you click the download link, the browser sends a new request to the attachment URL without the required authentication credentials.
The server responds with an authentication challenge, causing the browser to display the login prompt. After the request completes, the authentication is not maintained for subsequent requests, so the next download prompts for credentials again.
Video: How to Make REST Attachment API Requests
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
3 weeks ago
each instance URL requires authentication without which you can't access the resource.
It's out of the box behavior
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader