Greetings,
I have a Google App Script Code that connects to my Mongo DB for a Web app. However, when the post request is sent to findone it actually returns a null and the error in the log is “failed to set response” on Mongodb Logs.
Any help would be appreciated in helping me understand why i cannot seem to make the call to load the information.
The document that is pulled is quite a long array of data. Not sure if that is the reason or if there is a limit of what can be pulled.
> const findEndpoint = 'https://data.mongodb-api.com/app/XXXXX/endpoint/data/v1/action/findOne';
const clusterName = "ClusterNAME"
function lookupInspection() {
const apikey = 'API KEY'
const query = { edate: '2022_09_27'}
//We can Specify sort, limit and a projection here if we want
const payload = {
filter: query,
collection: "COLNAME", database: "DB NAME", dataSource: clusterName
}
const options = {
method: 'post',
contentType: 'application/json',
accept: 'application/json', // THIS WAS ADDED TO SEE IF IT NEEDED TO ACCEPT RESPONSE AS WELL.
payload: JSON.stringify(payload),
headers: { "api-key": apikey },
muteHttpExceptions: true
};
const response = UrlFetchApp.fetch(findEndpoint, options);
Logger.log(response.getContentText())
const documents = JSON.parse(response.getContentText()).documents
Logger.log(documents)
}