Sharepoint Onedrive API word to pdf format download operation failed time out issue
I am reaching out regarding an issue I am encountering while attempting to download a PDF file using the SharePoint REST API. Specifically, I am receiving a "Timeout" error when attempting to download a PDF file from the following endpoint:
URL: https://atachisystemssanjose-my.sharepoint.com/_api/v2.0/me/drive/items/{itemId}/content?format=pdf
Issue Summary:
I am making a GET request to the SharePoint API to retrieve a file in PDF format. However, I am encountering a timeout error when the request is executed. I have attempted to configure timeouts in both Java and Python, as well as in my client-side JavaScript, but the issue persists. Below is the relevant code snippet I am using in JavaScript for this request.
var url = "https://atachisystemssanjose-my.sharepoint.com/_api/v2.0/me/drive/items/" + id + "/content?format=pdf";
var method = 'GET';
var xhr = createCORSRequest(method, url);
xhr.onload = function(response) {
if (response.target.status == 200) {
var webUrl = response.originalTarget.responseURL;
} else {
alert("Please Refresh the Page (or) Check CORS Plugin Enabled");
}
};
xhr.onerror = function() {
sql
// Error handling logic
};
xhr.setRequestHeader('Authorization', 'Bearer ' + GlabalAccess_token);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Prefer', 'respond-async');
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
xhr.send();
Steps Taken to Troubleshoot:
- Timeout Configuration: I have set appropriate timeouts in Java, Python, and JavaScript, but the request still times out.
- CORS Issues: I have ensured that the CORS plugin is enabled, and the necessary headers (such as
Access-Control-Allow-Origin
) are set correctly. - Token Authorization: I am using a valid access token for authentication.
- API Documentation: I have consulted multiple online resources and Microsoft documentation but have been unable to resolve the issue.
Request:
- Could you kindly review the situation and provide guidance on resolving this timeout issue when accessing the SharePoint API endpoint?
- Are there any specific configurations or limits that may be causing this timeout?
- If there are any best practices for making this request more reliable, I would greatly appreciate your input Steps Taken to Troubleshoot:
- Timeout Configuration: I have set appropriate timeouts in Java, Python, and JavaScript, but the request still times out.
- CORS Issues: I have ensured that the CORS plugin is enabled, and the necessary headers (such as
Access-Control-Allow-Origin
) are set correctly. - Token Authorization: I am using a valid access token for authentication.
- API Documentation: I have consulted multiple online resources and Microsoft documentation but have been unable to resolve the issue.