0

Their documentation example requires certain fields to be in the update body, but these values aren't always available. I've checked some instructions and this, for example, says that you only need to pass the one that you want to update, which is what I am doing. Keep getting 200, but the update doesn't actually happen.

const clickupToken = "***"
const clickupReqBody = { "Authorization": clickupToken }
const clickupUrl = "https://api.clickup.com/api/v2/"

function updateTaskStatusClickUp(updatedTaskData, taskId) {
  taskid = '476ky1';
  
  updatedTaskData = {
    "status": "COMPLETE"
  }
  
  const query = {
    custom_task_ids: 'false',
    team_id: '',
  };

  const resp = UrlFetchApp.fetch(
    clickupUrl + `task/` + `${taskId}?${query}`, {
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json',
        Authorization: clickupToken
      },
      body: JSON.stringify(updatedTaskData)
    }
  );
  console.log(resp.getContentText());
}

Appreciate your help!

onit
  • 2,275
  • 11
  • 25
  • When `body: JSON.stringify(updatedTaskData)` is modified to `payload: JSON.stringify(updatedTaskData)`, is that your expected result? [Ref](https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchurl,-params) `body` is replaced with `payload`. – Tanaike Oct 10 '22 at 13:30
  • Wow! At first, when I tried ```payload``` without ```JSON.stringify()```, believing that it was already in the correct format, it threw an ```Exception related error```, but when stringifying it, it DOES work! Thank you, @Tanaike!! – onit Oct 10 '22 at 13:35
  • Thank you for replying. I'm glad your issue was resolved. When your issue was resolved, can you post it as an answer? By this, it will be useful for other users who have the same issue. – Tanaike Oct 10 '22 at 13:37

1 Answers1

1

It turns out that the body needs to be payload: JSON.stringify(), as clarified by Google Apps Script legend, in the question comments above.

const clickupToken = "***"
const clickupReqBody = { "Authorization": clickupToken }
const clickupUrl = "https://api.clickup.com/api/v2/"

function updateTaskStatusClickUp(updatedTaskData, taskId) {
  taskid = '476ky1';
  
  updatedTaskData = {
    "status": "COMPLETE"
  }
  
  const query = {
    custom_task_ids: 'false',
    team_id: '',
  };

  const resp = UrlFetchApp.fetch(
    clickupUrl + `task/` + `${taskId}?${query}`, {
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json',
        Authorization: clickupToken
      },
      payload: JSON.stringify(updatedTaskData)
    }
  );
  console.log(resp.getContentText());
}
onit
  • 2,275
  • 11
  • 25