I have an HTTPS onRequest function that expects an argument inside the req.body. I am calling this function from a cloud task and because of that, I have to define a httpRequest like so:
//this is the request:
const task: tasks.protos.google.cloud.tasks.v2.ITask = {
httpRequest: {
httpMethod: 'POST',
url,
body: Buffer.from(JSON.stringify(payload)).toString('base64'),
headers: {
'Content-Type': 'application/json',
},
},
scheduleTime: {
seconds: 7200 + Date.now() / 1000
}
}
//this is my function
functions.https.onRequest((req, res) => {
const payload = req.body as IScrapeTaskArguments;
});
This works as intended but I would like to be able to call this function manually.
How can I define the requests body if I want to manually test the function (call it from the browser)
Without an add-on or using a website tool, you cannot manually create HTTP POST requests. The browser address bar will only issue HTTP GET requests.
A very popular developer tool is Postman. This runs in the browser and as an installable app.
Developers also use the CLI tools such as curl. Curl is an amazing tool that you must have in your toolbox.