According to https://developer.openstack.org/api-ref/container-infrastructure-management/#create-new-cluster all I would need to create the cluster is pass the parameters like:
curl --header "X-Auth-Token: blah" \
-X POST https://myopenstack:9511/v1/clusters -d name="Swarm-cluster-ansible" -d cluster_template_id="7402f9d3-4881-440f-8496-08d420935f58" -d node_count=2 -d keypair="k8s-gitlab-ci"
It is giving me:
{"errors": [{"status": 400, "code": "client", "links": [], "title": "Unknown argument: \"cluster_template_id, node_count, keypair, name\"", "detail": "Unknown argument: \"cluster_template_id, node_count, keypair, name\"", "request_id": ""}]}
If I try it this way:
curl --header "X-Auth-Token: blah" \
-X POST https://myopenstack:9511/v1/clusters -d cluster='{
"name":"swarm",
"master_count":1,
"discovery_url":null,
"cluster_template_id":"7402f9d3-4881-440f-8496-08d420935f58",
"node_count":1,
"keypair":"k8s-gitlab-ci",
"master_flavor_id":null,
"labels":{
},
"flavor_id":null
}'
{"errors": [{"status": 400, "code": "client", "links": [], "title": "Invalid input for field/attribute cluster", "detail": "Invalid input for field/attribute cluster. Value: '{\n \"name\":\"swarm\",\n \"master_count\":1,\n \"discovery_url\":null,\n \"cluster_template_id\":\"7402f9d3-4881-440f-8496-08d420935f58\",\n \"node_count\":1,\n \"keypair\":\"k8s-gitlab-ci\",\n \"master_flavor_id\":null,\n \"labels\":{\n },\n \"flavor_id\":null\n}'. unable to convert to Cluster. Error: __init__() takes exactly 1 argument (2 given)", "request_id": ""}]}
Any idea?
EDIT: I am able to do a GET and retrieve the list of existing clusters.
-H "Content-Type: application/json" is enough in this case so the body is interpreted as JSON.
Related
The execution_date_gte parameter seems to have no effect in below Airflow REST API dagRuns call.
curl -X GET 'http://localhost:8080/api/v1/dags/demand_forecast/dagRuns' -H 'Cache-Control: no-cache' -H 'Content-Type: application/json' -d '{"execution_date_gte": "2023-02-02T00:00:00+00:00"}' --user "airflow:airflow"
Response:
{
"dag_runs": [
{
"conf": {},
"dag_id": "demand_forecast",
"dag_run_id": "scheduled__2022-02-15T00:00:00+00:00",
"end_date": "2022-08-22T08:46:37.026194+00:00",
"execution_date": "2022-02-15T00:00:00+00:00",
"external_trigger": false,
"logical_date": "2022-02-15T00:00:00+00:00",
"start_date": "2022-08-22T08:46:15.451700+00:00",
"state": "success"
}
],
"total_entries": 1
}
Here the returned dag run has an execution_date which is smaller than provided execution_date_gte (=2023-02-02T00:00:00+00:00).
execution_date_gte should be passed as a query parameter to the GET request.
I'm trying to use the new LinkedIn Posts API to make a post. I started by trying to duplicate the curl sample code at
https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-06&tabs=curl#text-only-post-creation-sample-request
curl -X POST 'https://api.linkedin.com/rest/posts \
-H 'Authorization: Bearer {INSERT_TOKEN}' \
-H 'X-Restli-Protocol-Version: 2.0.0' \
-H 'LinkedIn-Version: {version number in the format YYYYMM}' \
-H 'Content-Type: application/json' \
--data '{
"author": "urn:li:organization:5515715",
"commentary": "Sample text Post",
"visibility": "PUBLIC",
"distribution": {
"feedDistribution": "NONE",
"targetEntities": [],
"thirdPartyDistributionChannels": []
},
"lifecycleState": "PUBLISHED",
"isReshareDisabledByAuthor": false
}'
I replaced the bearer token with my own, and changed the author to urn:li:person:{my id}
I get the following error suggesting that I a have asked for a specific adContext:
{"errorDetailType":"com.linkedin.common.error.BadRequest","code":"MISSING_REQUIRED_FIELD_FOR_DSC","message":"Field /adContext/dscAdAccount is required when the post is a Direct Sponsored Content, but missing in the request","errorDetails":{"inputErrors":[{"description":"Field /adContext/dscAdAccount is required when the post is a Direct Sponsored Content, but missing in the request","input":{"inputPath":{"fieldPath":"/adContext/dscAdAccount"}},"code":"MISSING_REQUIRED_FIELD_FOR_DSC"}]},"status":400}
In the hope that that was the default, I added an adContext "adContext": {"isDsc": False}
and that gave me {"errorDetailType":"com.linkedin.common.error.BadRequest","code":"UNPROCESSABLE_ENTITY","message":"ReadOnly field present in a create request","errorDetails":{"inputErrors":[{"description":"ReadOnly field present in a create request","input":{"inputPath":{"fieldPath":"/adContext/isDsc"}},"code":"UNPROCESSABLE_ENTITY"}]},"status":400}
I also tried a blank adContext.
Has anyone had any luck using this API, or can anyone tell me what I'm doing wrong?
I'm trying to scrape an Amazon page with browserless:
curl -X POST \
"https://chrome.browserless.io/content?token=<token>" \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d ' {
"url": "https://www.amazon.com/gp/your-account/order-details/?orderID=114-5444651-3149007",
"elements": [{
"selector": "a",
}],
"cookies": [
<many cookies>
],
}'
but I keep getting:
[{"message":"\"elements\" is not allowed","path":["elements"],"type":"object.unknown","context":{"child":"elements","label":"elements","value":[{"selector":"a","timeout":10000}],"key":"elements"}}]%
If I exclude the elements object, it works fine but returns the entire 6,000 lines of <html>.
(What I actually want is document.getElementsByClassName('shipment')[0].innerText)
When I try the examples (from the docs) they work fine.
Its because elements only available for /scrape API
You are using /content
I am getting the below error when trying to query PUT command with curl :
"error":"bad_request","reason":"Missing request body"
this is the query i am trying to execute to insert a new document in the database:
curl -X PUT http://127.0.0.1:5984/mychannel_fabcar/CAR10/ '{"docs" : [ "_id": "CAR10", "colour": "white","make": "Ford", "model": "Figo","owner": "Meghna","~version": "\u0000CgMBAgA="]}'
shouldn't you also give the option -d for the body?
curl -X PUT http://127.0.0.1:5984/mychannel_fabcar/CAR10/ -d '{"docs": [ "_id": "CAR10", "colour": "white","make": "Ford", "model":"Figo","owner": "Meghna","~version": "\u0000CgMBAgA="]}'
see this thread (uploading files) and this thread (uploading raw data) for a detailed explanantion.
Facing an issue with a simple requirement.
Make a CURL request and store in a variable
Parse JSON from variable using JQ and output into CSV file.
When I try to do it, I am getting extra leading space in the file from the second line for some reason. Is there a way to configure jq to not do this ?
Code :
output=`curl -v -k -H 'Content-Type: application/json' '<<URL>>' -d '<<PARAMS>>'`
csvOutput=`echo $output | jq --raw-output '.result .items[]|[.name,.key,.created,.updated]|#csv'`
echo $csvOutput >> out.csv
The following code (all in one line) does not have the issue. But I need the curl output in a variable to perform some checks ,so this option does not help.
echo "$(curl -v -k -H 'Content-Type: application/json' '<<URL>>' -d '<<PARAMS>>" | jq -r '.result .items[]|[.name,.key,.created,.updated]|#csv' >> out.csv
Strangely, when I read the json output (taken from curl response) from a file and then apply jq filters, I don't see the issue.
cat response.json | jq -r '.result .items[]|[.name,.key,.created,.updated]|#csv' > out.csv
response.json (formatted) :
{
"result": {
"total_items": 22,
"total_pages": 1,
"items_per_page": 1000,
"current_page": 1,
"items": [
{
"key": "1",
"name": "Name 1",
"created": "2016-12-20T08:51:13Z",
"updated": "2016-12-20T09:29:08Z"
},
{
"key": "2",
"name": "Name 2",
"created": "2016-12-20T08:51:13Z",
"updated": "2016-12-20T09:29:08Z"
},
{
"key": "3",
"name": "Name 3",
"created": "2016-12-20T08:51:13Z",
"updated": "2016-12-20T09:29:08Z"
}
]
},
"id": 1
}
When you write your result to your csv file your are using echo $csvOutput >> out.csv instead of :
echo "$csvOutput" >> out.csv
The double quotes will preserve newlines, see this post