Using the ClickUp API from within Anvil

I followed the ATS tutorial (https://anvil.works/learn/tutorials/trello-api-applicant-tracking-system/chapter-1) and it worked great.

I want to do something similar but with ClickUp (clickup.com) instead of Trello.

Has anyone tried something like this and could kindly show me an example of how to communicate with the ClickUp API from Anvil?

1 Like

So reading the clickUp API documentation a little bit ClickUp™ | API Docs , It looks like your standard api where you send you authentication in the header.

You could follow the same steps in chapter step 3 of the trello tutorial to send data to ClickUp OR you could use anvils https library.

Which is pretty clean and I’ve enjoyed using :slight_smile:

Hope this helps!

Thank you for pointing me to the HTTP module - it just works :grinning:

1 Like

BUT… I ran into a problem: I am able to return json with GET requests but not with POST requests. Whenever I try to set json=True I receive:
“HttpErrorStatus: HTTP error 400 at /downlink/anvil/http.py, line 66 called from [ServerModule1, line 50](javascript:void(0)) called from [Form1, line 12](javascript:void(0))”

Do you have example code to look at?

The following server module code works (a list with the set name and content is created in ClickUp) and >_Output window shows “<anvil.BlobMedia object>”. But I want to see json there. All my attempts to set json=True somehow leads to an 400 error. Any idea?

import anvil.secrets
import anvil.server
import anvil.http

key = anvil.secrets.get_secret("clickup_token")

@anvil.server.callable
def access_xkcd_api(space_id):
  values = """
      {
      "name": "Liste24",
      "content": "ListenInhalt24",
      "due_date": 1567780450202,
      "due_date_time": false,
      "priority": 1
      }
    """

  headers = {
    "Authorization": key,
    "Content-Type": "application/json"
  }
  
  resp = anvil.http.request(url=f"https://api.clickup.com/api/v2/space/{space_id}/list", method="POST", data=values, headers=headers)
  
  return resp

is the output the resp from click up?

I would try making a request on POSTMAN and see if that gives you the same issue.

If not, maybe try using the request library instead of anvils http library…hard to debug without a clone in this situation, which I get is not feasible because you’d have to share your credentials or I would have to sign up to click up.