React Post - Failed to read the request form. Missing content-type boundary

31 Views Asked by At

Error:

Failed to submit form data: {"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-fdda1dac095716c63825b02466442e3b-9b4d9bc09fab1e4e-00","errors":{"":["Failed to read the request form. Missing content-type boundary."]}}

Code:

const handleSubmit = async (event) => {
    event.preventDefault();

    try {
      const response = await fetch("http://192.168.1.73:5077/api/Account", {
        method: "POST",
        body: JSON.stringify(formData),
        headers: {
          "Content-Type": "multipart/form-data",
        },
      });

      if (response.ok) {
        console.log("Form data submitted successfully");
        alert("Form data submitted successfully");
        router.push("/login");
      } else {
        const errorMessage = await response.text();
        console.error(`Failed to submit form data: ${errorMessage}`);
        alert(`Failed to submit form data: ${errorMessage}`);
      }
    } catch (error) {
      console.error("Error:", error);
    }
};

Swagger API Structure:

enter image description here

enter image description here

Please help me out on this as I am not able to Post/Submit data.

For frontend, I'm using React Next JS.

The backend is an ASP.NET Web API

0

There are 0 best solutions below