title: Ionic3 multipart form image upload
body: <p>I want to upload multipart form data to restapi, the api is working fine when it is requested on Postman client.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>takePhoto() {  
    const options: CameraOptions = {  
      quality: 100,  
      allowEdit: true,  
      targetWidth: 200,  
      targetHeight: 200,  
      saveToPhotoAlbum: true,  
      encodingType: this.camera.EncodingType.JPEG,  
      mediaType: this.camera.MediaType.PICTURE 
    };  
  
    this.camera.getPicture(options).then(image =&gt; {  
      console.log('Image URI: ' + image);  
       this.image_File = image;  
       this.imgfile = this.imageURI;  
      console.log(JSON.stringify(this.imageURI));  
      this.avatar = image.slice(7);  
      this.imgfile = this.avatar;  
    }, error =&gt; { 
      console.log('Error: ' + error);  
    });
  }  
  </code></pre>
  
  <p>For uploading the file I defined a function:</p>
  
  <pre><code>console.log("begin to upload ");  
  let link = rootUrl+"merchant/merchant-image";  
  let data = new FormData();  
  // var blob = new Blob([this.image_File], { type: "image/jpg" });  
  data.append('merchantId', '2');  
  data.append('merchantImage',this.imgfile);  
  
  console.log(data);  
  this.http.post(link, data,{ 
    headers:{  
      "Accept-Language":this.lang,  
      //'enctype': 'multipart/form-data',  
     // 'Content-Type': 'multipart/form-data',  
    } 
  }).subscribe(data2 =&gt; {   
    console.log("data Successful "+ data2);  
  }, error =&gt; {   
    console.log("Oooops! error "+ JSON.stringify(error));  
  });    
  </code></pre>
  
  <p>Response from server:</p>
  
  <pre><code>{ 
    "headers": {
      "normalizedNames": {},
      "lazyUpdate": null
    },
    "status": 400,
    "statusText": "OK",
    "url": "http://xxxxxxxxxxx/merchant/merchant-image",
    "ok": false,
    "name": "HttpErrorResponse",
    "message": "Http failure response for http://xxxxxxxxxxxxx/merchant/merchant-image: 400 OK",
    "error": {
      "timestamp": "2018-08-14T10:13:14.693+0000",
      "status": 400,
      "error": "Bad Request",
      "message": "Required request part 'merchantImage' is not present",
      "path": "/api/v1/merchant/merchant-image"
    }
  }
  </code></pre>