Thursday, September 1, 2022

[SOLVED] Dataform POST API call issue with TAGS option

Issue

I would like to run an API call to Dataform using tags but no success.

The curl below runs "ALL ACTIONS" instead of labeled flows.

Here's my call: curl -H "Authorization: Bearer <MY_KEY>" -X POST -d '{ "tags": ["monthly_sales"] }' https://api.dataform.co/v1/project/<PROJECT_ID>/run

With or without the tags option inside the -d the result is the same, it runs all my queries within my project instead of runs only the labeled "monthly_sales" queries.

Here's the DOC

What's wrong with my call? Maybe Dataform is still on beta version?


Solution

I found the solution.

curl -H "Authorization: Bearer <MY_KEY>" -X POST -d '{"runConfig": {"tags": ["monthly_sales"]}}' https://api.dataform.co/v1/project/<PROJECT_ID>/run

And here's the python code to do it:

import requests

url = "https://api.dataform.co/v1/project/<PROJECT_ID>/run"

headers = {}
headers["Content-Type"] = "application/json"
headers["Authorization"] = "Bearer <MY_KEY>"

data = '{"runConfig": {"tags": ["monthly_sales"]}}'

resp = requests.post(url, headers=headers, data=data)

print(resp.json())


Answered By - Fares DAOUD
Answer Checked By - Terry (WPSolving Volunteer)