Trouble Sending form data to a serverless function
Hello
What I'm trying to do is submit an HTML form and have my serverless function handle the data sent over then return the result of the function to the page
I referenced this from the serverless function documentation:
Using serverless functions with the form element When submitting serverless functions use javascript to handle the form submission, and use the "contentType" : "application/json" header in your request. Do not use the <form> elements action attribute.
The response I get back is: Request Forbidden after the page reloads
I'm wondering am I setting something up incorrectly?
Also, how does the serverless function handle the data it' been sent is there a default package that can handle the request, or will I need to find one?
I took a look at your serverless.json file and noticed that you changed the update-acc-order endpoint to acc-order shortly after posting this question. Are you still encountering 403 errors with the new endpoint URL?
If so, are you able to make successful one-off POST requests in a REST client like Postman? If not, do you have a sample JSON payload I can test with?
Per your second question, HubSpot serverless functions do not use a default package to handle incoming POST requests. It looks like you've already figured out a way to handle these in update-acc-order.js, though. Am I correct?
I changed the format of the body and spelling of "acessory" to:
{
"accessory": "71314"
}
and made a POST request directly in Postman. It does return a 400 Bad Request response but the empty validation message ({}) suggests the error lies within the update-acc-order.js script itself.