title: Symfony 5 - HttpClient, Add "Authorization bearer 123456789azertyuiop" in headers data
body: <p>I would like to attach authentication information in the header of an HTTP request using HttpClientInterface.<br />
  (<em>I already have 45 other methods that work very well</em>) but my problem occurs when I <strong>try to send a file</strong> with the <strong>multipart/form-data content-type</strong>.<br />
  I take the code from the original <a href="https://symfony.com/doc/current/http_client.html#uploading-data" rel="nofollow noreferrer">documentation</a> below to stay on a very simple case but I can't join my data in the generated ones.</p>
  <pre class="lang-php prettyprint-override"><code>use Symfony\Component\Mime\Part\DataPart;
  use Symfony\Component\Mime\Part\Multipart\FormDataPart;
      
  $formFields = [
      'regular_field' =&gt; 'some value',
      'file_field' =&gt; DataPart::fromPath('/path/to/uploaded/file')
  ];
  $formData = new FormDataPart($formFields);
  $client-&gt;request('POST', 'https://...', [
      'headers' =&gt; $formData-&gt;getPreparedHeaders()-&gt;toArray(),
      'body' =&gt; $formData-&gt;bodyToIterable(),
  ]);
  </code></pre>
  <p>Here's what I'm trying to do</p>
  <pre class="lang-php prettyprint-override"><code>$myHeader = [
      'Authorization' =&gt; 'Bearer ' . $this-&gt;getUser()-&gt;getToken()
  ];
  $params = [
      'headers' =&gt; array_merge($myHeader, $formData-&gt;getPreparedHeaders()-&gt;toArray()),
      'body'    =&gt; $formData-&gt;bodyToIterable(),
  ];
  </code></pre>
  <p>And here's how it's translated so the API doesn't understand what I send it and return me back a <strong>400 bad request</strong></p>
  <pre class="lang-php prettyprint-override"><code>&quot;headers&quot; =&gt; [
      &quot;Authorization&quot; =&gt; &quot;Bearer eecd39xxxxxxxxede8e66433d3aea693&quot;
      0 =&gt; &quot;Content-Type: multipart/form-data; boundary=ujDYAsPF&quot;
  ]
  </code></pre>
  <p>It's a relatively common case in principle so I guess there is a solution?  thank you.</p>