Trying to create a function returns
https status code 413
with a message of
{"error":"read size limit exceeded","error_code":"ReadSizeLimitExceeded"}
example node.js code that uses node-fetch npm package for http:
async function deploy() {
const accessToken = await getAccessToken();
console.log("accessToken", accessToken);
const body = {
"can_evaluate": {},
"name": "slidesTriggerHandler",
"private": true,
"source": fs.readFileSync(path.join(__dirname, "./functions/slides/dist/index.js"))
};
const appId = await getAppId();
console.log("appId", appId);
const projectId = "someprojectId";
const url = `https://realm.mongodb.com/api/admin/v3.0/groups/${projectId}/apps/${appId}/functions`;
const res = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`,
},
body: JSON.stringify(body)
});
if (res.ok) {
console.log(await res.json());
} else {
console.log(res.status);
console.log(await res.text());
}
}
Also feedback, it’s highly frustrating that there is no information description on error codes on any of the APIs.