Forum Discussion
Jedrek96
Aug 28, 2023Copper Contributor
Unable to fetch my search file type filter through HTTPS but able to get through HTTP
Hello all,
I am currently facing an issue where my file type cannot be retrieved via HTTPS however it can be downloaded via HTTP. Is there a workaround for this? I want to retrieve the file via HTTPS. Please do assist! Thank you!
Here is my code:
<!DOCTYPE html>
<html>
<head>
<title>File Filters</title>
</head>
<body style="background-color: black; color: aliceblue;" >
<h1 style="color: darkmagenta;">Search Queries</h1>
<button id="powerpointButton">Search PowerPoint</button>
<button id="wordButton">Search Word</button>
<button id="excelButton">Search Excel</button>
<h2>Search Results:</h2>
<div id="results" style="color:aliceblue !important"></div>
<script>
async function testFilter(searchURL) {
const xhr1 = new XMLHttpRequest();
xhr1.open("GET", searchURL);
xhr1.setRequestHeader("accept", "application/json;odata=verbose");
xhr1.onreadystatechange = async function () {
if (xhr1.readyState === 4) {
if (xhr1.status === 200) {
const response = JSON.parse(xhr1.responseText);
console.log(`XHR1 Success!!`, response);
// Extract URLs of document files from the response
const results = response.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;
const resultsDiv = document.getElementById("results");
resultsDiv.innerHTML = "";
for (const result of results) {
const extension = result.Cells.results.find(cell => cell.Key === 'FileExtension').Value;
if (extension && extension.toLowerCase() !== 'aspx') {
const title = result.Cells.results.find(cell => cell.Key === 'Title').Value;
const url = result.Cells.results.find(cell => cell.Key === 'Path').Value.replace("https://", "http://");
resultsDiv.innerHTML += `<p><a href='${url}'>${title}</a></p>`;
}
}
} else {
console.error('XHR1 Error:', xhr1.statusText);
}
}
};
xhr1.send();
}
document.getElementById("powerpointButton").addEventListener("click", function() {
testFilter(searchURL);
});
});
</script>
</body>
</html>
Here is the error:
The file at 'http://www.test.com/Shared%20Documents/2%20Test%20Powerpoint.pptx' was loaded over an insecure connection. This file should be served over HTTPS.
No RepliesBe the first to reply