However whenever I submit I am getting an error saying that the required submiect field is not in the request.
Here is the error response
{"status":"error","message":"The request is not valid","errors":[{"message":"Error in 'fields.subject'. Required field 'subject' is missing","errorType":"REQUIRED_FIELD"}],"requestId":"a1374efe-f791-48d0-83aa-413d55def461"}
Here is what I am Posting:
submitToHubSpot = () => {
let url: string = "https://api.hsforms.com/submissions/v3/integration/submit/<valid portal Id here>/<valid form id here>";
var param: any = {
fields: [
{
"name": "email",
"value": "cchristians@innovasi.com"
},
{
"name": "firstname",
"value": "Chad"
},
{
"name": "lastname",
"value": "Chad"
},
{
"name": "subject",
"value": "Testing Subject"
}
]
} // http.post is a wrapper for AJAX
http.post(url, param).then((result: any) => {
console.log(result);
});
}
Are you sure that you're using the correct internal name for the subject field? I wonder if you have another property labeled subject, but whose internal name is something different. Because in that case, the API wouldn't recognize that all of this form's required fields are actually being submitted, which is what that error message indicates.
Otherwise I'm happy to take a look. Just let me know the form ID and portal ID and I'll take a look. You can respond here or through a DM if you'd prefer.
It looks like maybe you're using TypeScript? I honestly am not very familiar with it, but I believe TypeScript compiles down to vanilla JS. Is it possible for you to paste your compiled request? I just wonder if your code is compiling into something that we're not expecting. Because I can make a request using the following:
That's for a form in my own account, which you can use if you'd like, or feel free to plug in your account ID and form ID. And you should see that it submits correctly. So I don't know if that helps, but I suspect that your code is compiling into something that doesn't look right. So if it's possible to see that, I think that will help here. Or if I'm wrong about any of the above, let me know and I'll dig in a little more.
So there must be some issue with our form as when I use your URL with my code everything works just fine. I am not the creator of our support form so Ill have to talk to him to see if we can figure it out.