Uploading Profile Pic with NodeJS

Description
I am trying to upload a profile picture with Node.js and the form-data/axios modules and nothing is working

Error
Response contains:

{ data: { code: -1, message: “Required request part ‘pic_file’ is not present” } }

Which App Type (OAuth / Chatbot / JWT / Webhook)?
OAuth

Which Endpoint/s?
/v2/users///picture

How To Reproduce (If applicable)
Code I’m using:

const img = request.body.base64img;
const imgParts = img.split(’,’);

const userid = request.body.userid;

const stream = bufferToStream(Buffer.from(imgParts[1], ‘base64’));

let formData = new FormData();
formData.append(‘pic_file’, stream);

axios.post(https://api.zoom.us/v2/users/${userid}/picture, formData, {
headers: {
…formData.getHeaders(),
‘Authorization’: Bearer ${adminToken.admin_token}
}
}).then(response => {
console.dir(response);
}).catch(err => {
console.log(err);
});

bufferToStream just takes a Buffer and converts it to a stream … I was only trying that to see if it worked.

Anyone have any experience with this?

Hey @daniel1,

Have you tried the Node.js sample code on our docs?

var http = require("https");

var options = {
  "method": "POST",
  "hostname": "api.zoom.us",
  "port": null,
  "path": "/v2/users/me/picture",
  "headers": {
    "content-type": "multipart/form-data;",
    "authorization": "Bearer access_token"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();

Thanks,
Tommy