title: Getting data as null at the backend when sending an array of objects using formdata in React JS
body: <p>I want to send an array of objects inside formdata in React JS. When I am appending data inside formdata, it is being received as null at the backend and the API is returning me 500 internal server error. I have tried some of the solutions from the internet but not much support was found. The ways that I have tried till yet are mentioned below:</p>
  <pre><code>const surveyFormAnswers = [{Answer: &quot;Hello&quot;, QuestionId: 1}, {Answer: &quot;Document&quot;, QuestionId: 2, File: file (object)];
  
  const data = new FormData();
  data.append('SurveyFormAnswersDtos', JSON.stringify(surveyFormAnswers));
  await executeAddSurveyFormAnswers({data: data});
  </code></pre>
  <p>In this case, I am sending a stringified array at the backend (I can see my array being sent inside the browser's Network tab), but at backend, we are using dotnet core5.0. We do not know how exactly can we deseriliaze or parse our request data.</p>
  <p>In the second approach, I am appending my data manually inside the formdata (got this approach from the internet) but this is also sending me 500 internal server error from the backend. My code in this case looks like below:</p>
  <pre><code>const data = new FormData();
  for (var i = 0, valuePair; (valuePair = surveyFormAnswers[i]); i++)
    for (var j in valuePair) data.append(j, valuePair[j]);
  await executeAddSurveyFormAnswers({data: data});
  </code></pre>
  <p>I am also attaching a postman screenshot so that you can check the required format of data to be sent</p>
  <p><a href="https://i.stack.imgur.com/ina7Q.png" rel="nofollow noreferrer">Click on the link below to see data being sent using postman</a></p>
  <p>I have been using customized hook for axios and the definition for AddSurveyFormAnswers is below:</p>
  <pre><code>export function AddSurveyFormAnswersUrl(token) {
    return {
      url: `/SurveyAnswer/AddSurveyAnswers`,
      method: &quot;POST&quot;,
      headers: {
        Authorization: `Bearer ${token}`,
        ContentType:
          &quot;multipart/form-data; boundary=&lt;calculated when request is sent&gt;&quot;,
      },
    };
  }
  </code></pre>