Estoy tratando de crear una función en la nube de firebase para enviar automáticamente un formulario de Microsoft Office en línea. He escrito lo siguiente:
exports.covidForm = functions.pubsub.schedule('every 1 hours').onRun((context) => { var data = `{ "startDate": "2022-07-04T05:27:42.157Z", "submitDate": "2022-07-04T05:31:30.748Z", "answers": "[{\"questionId\":\"rc4588b6d25e8418b9dc6ead534c83ae9\",\"answer1\":\"Name\"},{\"questionId\":\"r3e87261178f94361b4fa8b61bb6d62e4\",\"answer1\":\"ID\"},{\"questionId\":\"r357b74d9ed964c3da24f0586f8cb7332\",\"answer1\":\"email\"},{\"questionId\":\"r14db4cece08b49a09f249e7e87d06c51\",\"answer1\":\"site\"},{\"questionId\":\"rc85571bd0c0b4027833c7d2f18f38b53\",\"answer1\":\"No\"},{\"questionId\":\"ra9a3c908d3204e21b37c08bec50f983d\",\"answer1\":\"No\"},{\"questionId\":\"rcf571f318ea54bffa41364a4f967d88c\",\"answer1\":\"No\"},{\"questionId\":\"ra09058c8546e489e865cd6ffd862c23c\",\"answer1\":\"No\"}]" }`; fetch("https://forms.office.com/formapi/api/.../forms('...')/responses", { method: 'POST', body: data, headers: { 'Content-Type': 'application/json' } }) .then(res => res.json()) .then(json => functions.logger.log(json)) .catch (err => functions.logger.log(err)) });Cuando ejecuto la función me devuelve un error:
{"errors":{"":["The input was not valid."]},"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-e52550913c0d8961deb46df79763ae95-06127511b66b74a6-00"} Pude enviar con éxito una publicación HTTP con reqbin.com con datos como JSON. Así que no entiendo por qué está fallando con mi función. 