{ //req.body.videoId is an integer a" /> { //req.body.videoId is an integer a" /> { //req.body.videoId is an integer a"/>

Vimeo add multiple tags doesn't work with tag array

25 views Asked by At

I have an application that needs to add multiple tags to a video. This is my code:

router.post("/", (req, res) => {
    //req.body.videoId is an integer as string, the video id is correct, I double checked it
    let path = `/videos/${parseInt(req.body.videoId)}/tags`;

    //Environment variables are correct, double checked

    const client = new Vimeo(
      process.env.VIMEO_CLIENT_ID,
      process.env.VIMEO_CLIENT_SECRET,
      process.env.ACCESS_TOKEN
    );
  
    const data = [ { name: '17-02-2024' }, { name: 'testtag' } ];

    client.request({
      method: "PUT",
      path: path,
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify(data),
    }, (error, body, statusCode, headers) => {
      if (error) {
        console.log("Error adding tags", error);
        res.status(500).send("Internal Server Error");
        return;
      }
      res.status(200).send("Tags added successfully");
    });
  });

For some reason I get this response:

Error adding tags Error: {"error":"Can not parse the request body"}

I checked the request body, reformatted it, checked everything but it still seems not to work. Any help is appreceated.

0

There are 0 answers