Looks like Airflow has an experimental REST api that allow users to create dag runs with https POST request. This is awesome.
Is there a way to pass parameters via HTTP to the create dag run? Judging from the official docs, found here, it would seem the answer is "no" but I'm hoping I'm wrong.
I had the same issue. "conf" value must be in string
curl -X POST \
http://localhost:8080/api/experimental/dags/<DAG_ID>/dag_runs \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"conf":"{\"key\":\"value\"}"}'
Judging from the source code, it would appear as though parameters can be passed into the dag run.
If the body of the http request contains json, and that json contains a top level key conf the value of the conf key will be passed as configuration to trigger_dag. More on how this works can be found here.
Note the value of the conf key must be a string, e.g.
curl -X POST \
http://localhost:8080/api/experimental/dags/<DAG_ID>/dag_runs \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"conf":"{\"key\":\"value\"}"}'
This is no longer true with the stable REST API.
You can do something like -
curl --location --request POST 'localhost:8080/api/v1/dags/unpublished/dagRuns' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw '{
"dag_run_id": "dag_run_1",
"conf": {
"key": "value"
}
}'
I understand that the question is asked for experimental API but this question is the top search result for airflow REST API.
Related
When trying to get historical events for some assets on Opensea, I noticed some asset can return events correctly. But some return empty array.
This is an example that worked:
curl --request GET \
--url 'https://api.opensea.io/api/v1/events?asset_contract_address=0xdcc2a6f7cf14b5d2fc0f2731faf0a37b914a0c82&token_id=2772&event_type=successful&only_opensea=false&offset=0&limit=20' \
--header 'Accept: application/json' \
--header 'X-API-KEY: XXXX'
However this does not work:
curl --request GET \
--url 'https://api.opensea.io/api/v1/events?asset_contract_address=0xa5f1ea7df861952863df2e8d1312f7305dabf215&token_id=150238&event_type=successful&only_opensea=false&offset=0&limit=20' \
--header 'Accept: application/json' \
--header 'X-API-KEY: XXXX'
The second attempt returns an empty events array:
{"asset_events":[]}
This is the path to that specific asset, you can see that there are actually some events on the item page:
https://opensea.io/assets/matic/0xa5f1ea7df861952863df2e8d1312f7305dabf215/150238
Any clue what is going on? Is this a bug on Polygon asset?
Opensea API does not support Polygon (yet).
The latest update of the POSTMAN (7.16) doesn't seem to understand the cURL when importing them.
Here is a cURL exported by POSTMAN itself via the "Code" option.
curl -L -X POST 'https://example.com/example/' \
-H 'Content-Type: application/json' \
--data-raw '{
"requestFields":{
"address":"123, Main Street",
"ping":false
}
}'
But when this cURLis is tried to be imported to POSTMAN again, it doesn't populate the Body area of the request.
Is there a workaround?
According to https://airflow.apache.org/api.html I can trigger an Airflow DAG like so:
curl -X POST \
http://localhost:8080/api/experimental/dags/<DAG_ID>/dag_runs \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"conf":"{\"key\":\"value\"}"}'
This seems to work ok for me, but I cannot figure out how to access the key/value stuff in the conf object being passed in.
I tried this:
something = dag.params.get("key", "unknown")
But it doesn't seem to work.
Does anyone know how to do this?
I used kaa rest api for activate my configuration (using Postman), but i have no idea how to fill Parameter content type of configurationId . I have try
{
"id" : "98593",
"applicationId": "32769",
"schemaId": "65544" ,
"endpointGroupId": "98308"}
but I get HTTP/1.1 400 Bad Request, any suggestion will be appreciated.
Thanks
finally i can solve this problem,
You need to set your content-type to application/json and POST body just fill with configuration id
curl -v -S -u username:password -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '12423' 'http://localhost:8080/kaaAdmin/rest/api/activateConfiguration' | python -mjson.tool
I'm writing a quick and dirty deployment script and would like to disable and reenable a Pingdom check as part of it. How do I do that using something like cURL?
To pause a check:
curl -X PUT -u 'your#email:yourpassword' -H 'Content-Type: application/json' -H 'App-Key: yourapplicationkey' -d 'paused=true' https://api.pingdom.com/api/2.0/checks/checkid
To resume a check:
curl -X PUT -u 'your#email:yourpassword' -H 'Content-Type: application/json' -H 'App-Key: yourapplicationkey' -d 'paused=false' https://api.pingdom.com/api/2.0/checks/checkid
Replace your#email with your pingdom email.
Replace yourpassword with your pingdom password.
Replace yourapplicationkey with a generated key from the "Sharing" section in your account.
Replace checkid with the numeric ID you see in the browser URL when you click on your check in the Pingdom UI.
You can also use modern way - just API key instead of using also email/password.
First, generate your own API key in https://my.pingdom.com/app/api-tokens and then you can use curl commands like for pausing:
curl -X PUT \
https://api.pingdom.com/api/3.1/checks \
-H 'Authorization:Bearer YOURAPIKEY' \
-d 'paused=true&checkids=777'
or for resuming:
curl -X PUT \
https://api.pingdom.com/api/3.1/checks \
-H 'Authorization:Bearer YOURAPIKEY' \
-d 'paused=false&checkids=777'
Replace YOURAPIKEY with your real API key and 777 with valid check ID.
checkids can be also omitted, then all checks will be modified.