Can't add Action to Rule even though app is added to project

I have created a custom app server in Flask and I was able to install it to a project by going through the installation flow. However whenever I try to add the Action to the Rule, I click on my app’s action and it sends a get request to the Action Metadata endpoint, but I get the message something went wrong try again later. I even get a 200 response from the endpoint I made in my Flask app. Any idea as to why this is occurring.

When you send your response, in addition to returning a 200 are you also sending the metadata as shown here?
https://developers.asana.com/docs/get-action-metadata

1 Like

Yes I created a dict in python and using Flask’s jsonify feature I return that metadata in said format whenever the endpoint is hit

Hmm, OK. Are you sending your response pretty much instantly? I found that if I wait even a few seconds, Asana throws that error. They are not very patient at waiting for a reply! :wink:

You might also want to post the exact response you’re sending back, just in case I can spot any issues with it.

Resolved this with Sahil offline. Leaving a note here just in case others run into the same issue.

This is related to Asana’s App Components Security documentation about CORS: “Add cross-origin resource sharing (CORS) headers to responses

Instructions on how to add CORS for Python Flask App Server:

  1. pip install Flask-Cors
  2. Import Flask-CORS: from flask_cors import CORS
  3. Add CORS(app) after app = Flask(__name__)

Additionally for development use https.

Instructions on how to add https to Python Flask App Server (for development):

  1. In your terminal window run the following commands in the root directory of your Python Flask App Server (This step is the same as the “Enable HTTPS” step on the app-components-example-app README):

  2. openssl req -x509 -newkey rsa:2048 -keyout keytmp.pem -out cert.pem -days 365

  3. openssl rsa -in keytmp.pem -out key.pem

  4. If serving the application with python <APP_SERVER_NAME>.py command, add ssl_context=("cert.pem", "key.pem") to app.run. Otherwise, if the application is being served using the flask command use flask run --cert=cert.pem --key=key.pem

  5. After completing step 2, you should see something similar to the following in your command line Running on https://<HOST_NAME>:<PORT> (Press CTRL+C to quit)

  6. If you are on Google Chrome navigate to your app server https://<HOST_NAME>:<PORT>/ in the URL you should see a warning “Your connection is not private” type “thisisunsafe” on your keyboard. Close the tab after you have done this. (This is the same as the “If blocked by Chrome…” step on the app-components-example-app README)

  7. Remember to update Rule Actions "Run action URL " and “Form metadata URL” for your App in Asana’s developer console to use https://<HOST_NAME>:<PORT>/<YOUR_RULE_ACTION_RUN_ACTION_ENDPOINT> and https://<HOST_NAME>:<PORT>/<YOUR_RULE_ACTION_METADATA_ENDPOINT>

2 Likes

Thanks for posting this resolution, @John_Vu!

1 Like