Vaidehi S
Vaidehi S

Reputation: 1

Clockify - Add user is throwing Bad Request 400 error

I am trying to add a user to my workspace in Clockify however I am getting Bad Request Error: status Code 400.

Can someone help. The API docs are not very helpful. Not sure what is wrong, is it my payload is wrong or am I missing anything in headers?

Thanks for helping. Code below:

    const addUser = async (req, res) => {
    const url = `https://api.clockify.me/api/v1/workspaces/${workspaceId}`;
 
  try {
    const payload = JSON.stringify(req.body);
    console.log("DATA", payload); // prints {"email": "[email protected]"}

    const records = await axios.post(`${url}/users/`, payload, {
      headers: {
        "X-Api-Key": key,
        "content-type": "application/json",
      },
    });
    console.log("Response", records);
    res.status(200).json(records);
  } catch (error) {
    res.statusCode = error.response.status;
    res.json({
      msg: `Something went wrong. Error: ${error.response.status} with clockify data posting`,
    });
    console.log(
      `Something went wrong :confused:!!  Error with clockify data posting`,
      error.message
    );
  }
};

Upvotes: 0

Views: 202

Answers (1)

i.boruch
i.boruch

Reputation: 1

Adding User Via API to clockify is only possible when your workspace is on a paid subscription

Upvotes: 0

Related Questions