What I’m trying to do:
I am trying to complete a tutorial on implementing the Trello API and job application tutorial that is on Anvil’s website.
What I’ve tried and what’s not working:
Step 3 on this page is not making sense to me: Anvil | Adding automated emails using a Trello webhook
Where does the webhook code work? Right now I have it as below but I’m getting a syntax error:
Code Sample:
def reject_applicant():
# Trello sends two requests, first HEAD then POST. Checking for head request stops 505 on first request.
if anvil.server.request.method == "HEAD":
return {}
# Get the old list ID or return a falsy object if an old list ID isn't found.
previous_list_id = anvil.server.request.body_json.get('action', {}).get('data', {}).get('old', {}).get('idList')
# Check if card is being moved onto rejected list
if previous_list_id and previous_list_id != REJECT_LIST_ID:
card_id = anvil.server.request.body_json['action']['data']['card']['id']
email_from_card = get_email_address_from_card(card_id)
anvil.email.send(from_name="Derrick's Awesome Company Inc.",
to=email_from_card,
subject="Application for Player Support Manager at the Coolest Company Ever",
text="Sorry to say you aren't cool enough!")
$ curl --request POST \
--url 'https://api.trello.com/1/webhooks/?key=<API-KEY>&token=<API-TOKEN>&callbackURL=<APP-CALLBACK-URL>&idModel=<REJECT-LIST-ID>' \
--header 'Accept: application/json' ```
It says to open the command line and to run it, but where do I do that as well? It’s assumes knowledge I’m unfamiliar with. Any help would be great. Thanks!