POST multipart/form-data in Ionic Native HTTP


Hi All

Is there a way to do POST request with multipart/form-data in ionic native HTTP ?



try below example


1 Like

@vd_virani, Thanks for replying.

It is a great example, but to use this i’ll have to change a whole lot of my code. Below are some lines from my code, just see if you can suggest something in this approach:

let clientConfirmData = new FormData();
var blob = new Blob([this.signature], { type: ‘image/png’ });

clientConfirmData.append(“patientConfirmation”, blob);, clientConfirmData, headers)
.then(data =>{

                                        .catch(error => {

so, my question is does clientConfirmData has to be a JSON object for it to work, won’t it work with FormData type object ? ( http is from ionic native’s not angular’s)



Did you ever solve this? I need to send as multipart/form-data as required by the server


No, Ionic’s Native Http does not support FormData type objects, But you can use Angular’s Http to achieve the same.
In my case, the backend guys had to change the service to accept JSON Object instead of FormData Object.


Ionic does support FormData. To those who are looking for answer, following codes work

postFile(token:string, file:Blob){

        let url = WebService.API_POST_FILE + "?token="+token;
        let httpOptions = {
            headers: new HttpHeaders({
                'enctype': 'multipart/form-data; boundary=----WebKitFormBoundaryuL67FWkv1CA'
        let formData = new FormData();
        formData.append('file', file, 'test.jpg');

        console.log("post photo to URL at "+url);
        return this.http

Hey, this is angular’s http service. The question is for Ionic Native HTTP

1 Like

any help please face same issue can’t send selected file to my http post api end point :frowning:


Ionic native HTTP request accepts only, object and array formats with key value pairs are the string format.
we can pass file as a base64 string format.
in backend decode the base64 string.


For those who are looking for to upload images using Ionic Native HTTP. There is function called uploadFile() that you can use.