1

I have followed this link When i check response in my code

 imageUploaded(image:any){
      var headers = new Headers();
      headers.append('Content-Type','multipart/form-data')
      headers.append('Authorization',this.token);
      let formData: FormData = new FormData();
      formData.append('image', image.file);
  this.http.post(this.serverUrl+'photo/upload/user/'+this.userJson.user.public_id,formData, { headers: headers})
        .subscribe(
            response => {
                if(response.json().error_code == 0){
                alert('done')

                }else{
                    this.data = {};
                }
            }
        )
 }

When I verified my API with live the only differance I found in network is the content type For working API-----Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryl4oxlVSt9yblG8VC For me -----Content-Type:multipart/form-data

I am missing the boundary with content type.Can anyone please help me.Thanks.

3
  • If you want to use the boundary, just add it? headers.append('Content-Type','multipart/form-data; boundary=----WebKitFormBoundaryl4oxlVSt9yblG8VC') Commented Mar 31, 2017 at 7:22
  • HiFredrik,how can I get the value for boundary? Commented Mar 31, 2017 at 7:31
  • As far as I understand it, it's just a delimiter of your data parts, so it can basically by anything that will not appear in your data stream. Take a look at this answer: stackoverflow.com/a/20321259/2521893, or this: stackoverflow.com/a/2071407/2521893 Commented Mar 31, 2017 at 7:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.