Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

Attachment api download link is redirecting

sasharma815
Tera Contributor

sasharma815_0-1783933943969.png


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 

sasharma815_1-1783934023799.png

 

3 REPLIES 3

Vikram Reddy
Tera Guru

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.

  1. Same browser, already logged into the instance: the link opens fine, no prompt.
  2. Script or integration calling it: pass an OAuth token or basic auth credentials in the Authorization header.
  3. 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

Tanushree Maiti
Tera Patron

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.

 

KB3075555 When retrieving an attachment using Attachment API, the pop-up for login with username & p... 

Video: How to Make REST Attachment API Requests

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Ankur Bawiskar
Tera Patron

@sasharma815 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader