Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
How can make a HTTPS post to URL with Firebase Functions (Node js)

I am trying to create a firebase cloud function to automatically submit an online Microsoft Office Form. I have written the following:

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))
});

When I run the function it returns an 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"} 

I was able to successfully send a HTTP post with reqbin.com with data as JSON. So I'm not understanding why it is failing with my function.reqbin POST

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!