HttpClientModule multipart/form-data auth

Hi, I’m working on it for days and don’t know what to do anymore, so my problem:

      const headers   : HttpHeaders = new HttpHeaders()
        .set('Authorization', `Basic ${btoa(this.PUBLISHABLE_KEY)}`)
        .set('Content-Type',  'multipart/form-data;boundary=---011000010111000001101001');
       //.set('Content-Type',  '');
      const fileBlob  : any         = new Blob([fileImage], { type: `image/${mimeType}` });
      const fd        : FormData    = new FormData();
      fd.append('file',     fileBlob, fileName);
      fd.append('category', category);
      return this.http.post(url, fd, { headers });
      //return this.http.post(url, fd);
    

I used postman and it worked ok, but in my code nothing done.
I saw answers to get rid of Content-Type, but even if I put this = ‘’ I got CORS errors from server.
I don’t have access to the api it’s from a credit card.
I saw answers to get rid of headers, but I need to pass the authorization.

{“error”:{“status”:“API Configuration Error”,“status_code”:510,“type”:“processing_error”,“category”:“gateway_error”,“message”:“Internal server error”}}

Thanks in advanced.

That is good advice. Read the yellow warning section of the MDN entry on FormData.

That’s a completely separate issue. You’ll have to communicate with the backend operator about how to handle CORS.

Hi, rapropos, thanks for the attention, nice about the Content-Type now I understood, but when I try to send with ‘multipart/form-data;boundary=—011000010111000001101001’, I got this error:
“error”:{“status”:“Bad Request”,“status_code”:400,“type”:“invalid_request_error”,“category”:“missing_required_param”,“message”:“Missing required param: file. Please verify request parameters.”}}
The fileImage is in base64 and change to blob with this format: data:image/{this.fileSuffix};name={this.fileName};base64,axZ… I don’t know if I’m doing something wrong anymore. Thanks again.