request: Error when boolean value is sent to multipart/form-data upload

Hi,

I tried different combination for uploading image with form fields. I can only get either of them working. If i remove all fields leaving image only , then my request upload files successfully. If i put fields along with image, like i did below, it doesn’t work.

I tried different combination. None worked for me.

At server side i’m using mutler with expressjs.

Any help here would be great.

    var formParam = {
                title: "testing single image"
              , caption: "Caption of image to test"
              , tags:"spa, saloon"
              , trademark: "la saloon trademark"
              , is_cover_photo: false
              , image: fs.createReadStream(__dirname + '/fixtures/images/services/SpaSalon.jpg')

            };
            var r = request({
//                preambleCRLF: true
  //                , postambleCRLF: true
                 method: 'POST'
                , url: "/services/" + serviceFix.id + "/photos" 
        //      , body: formParam
                , formData: formParam
                , json: true
            }, function(err, res, body){
                console.log("body ", body);
                expect( body.errors.length ).to.be(0);
                expect(res.statusCode).to.be(200);
                serviceFix.photos.push(body.data);
                done();
            });

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

Thanks for taking the time to create that example.

The problem is with is_cover_photo: false parameter, that should be is_cover_photo: 'false' string instead.

I just posted a question in https://github.com/felixge/node-form-data/issues/137 take a look if you’re interensted in.