Activate KAA configuration using Server REST APIs - kaa

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

Related

Linkedin Api sample AdSupplyForecast does not work

Nowadays I am working on Linkedin AdSupplyForecast api to follow at the below reference,
https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads/advertising-targeting/ad-supply-forecasts#find-supply-by-criteriav2
However the sample code does not work also I can not find any extra description about criteriaV2.
Standart Api sample at the below and response is '{"message":"Invalid HTTP Request","status":404}'
curl -H "Authorization:Bearer XX" -H "Content-Type:application/json" "https://api.linkedin.com/v2/adSupplyForecasts?q=criteriaV2&account=urn%3Ali%3AsponsoredAccount%3A518121035&timeRange=(start: 1587639976000,end: 1589540776000)&campaignType=SPONSORED_UPDATES&competingBid=(bidType:CPM,bidPrice:(currencyCode:USD,amount:10))&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3Alocations:List(urn%3Ali%3AcountryGroup%3ANA))))),exclude:(or:(urn%3Ali%3AadTargetingFacet%3AstaffCountRanges:List(urn%3Ali%3AstaffCountRange%3A%2810001%2C2147483647%29))))"
I modified it and like as at the below but it send server error '{"message":"Internal Server Error","status":500}', would you share with me a correct sample of it ?
curl --location --request GET 'https://api.linkedin.com/v2/adSupplyForecasts?q=criteriaV2&account=urn:li:sponsoredAccount:518121035&timeRange.start=1587639976000&timeRange.end=1589540776000&campaignType=SPONSORED_UPDATES&targetingCriteria.include=and:List%28%28or:%28{encoded%20urn:li:adTargetingFacet:locations}:List%28{encoded%20urn:li:countryGroup:NA}%29%29%29%29&targetingCriteria.exclude=or:%28{encoded%20urn:li:adTargetingFacet:staffCountRanges}:List%28{encoded%20urn:li:staffCountRange:%2810001,2147483647%29}%29%29' \ --header 'Authorization: XXX'

Generate a cURL request from a Postman

I tried generating a cURL request from Postman (using code option of postman).
As the request contains an input pdf file, there are certain header properties that are being added by postman.
Below is the curl that is generated (almost similar, changed some header for security reasons), response received 500, internal Server Error, "Current request is not a multipart request"
http://localhost:8080/test \
-H 'Accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded,multipart/form-data; boundary=--------------------------895926775956600620357522' \
-H 'Some-Key: abcd' \
-H 'cache-control: no-cache' \
-F file=#/C:/path/to/my/file/abc.pdf
If you want to send the multipart request in Postman, you just need to do the following:
Don't specify a Content-Type in Header.
In Body tab of Postman you should select form-data and select file type
Read more here.

What does -d stand for in curl request?

I am trying to send this HTTP request in Postman application:
curl -v https://api.someurl.com/z1/lists \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: authorization" \
-d '{ "list_id": "DXVBDAD" }'
Any body knows what -d stands for? and where should I put it in Postman?
The documentation says this:
(HTTP) Sends the specified data in a POST request to the HTTP server[...]
So this will be the body of your POST request. In Postman you have to put it into the 'body' field. There select 'raw' and then select 'application/json'.
Because that's the Content-Type of your request, specified with -H.
The -d or --data option makes the curl command send data in POST request to the server. This option makes the curl command pass data to the server using content-type (JSON in your case) just as the browser does when a user submits a form.

Pass parameters to Airflow Experimental REST api when creating dag run

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.

Is it possible to use `--data-urlencode` and `--data-binary` options for the same curl command?

I am using curl and I would like to execute a HTTP PUT request by sending a --data-urlencode string and a --data-binary JSON file content. Is it possible to make that in the same curl command?
I tried the following
curl www.website.org --request PUT -H Content-Type: application/json --data-urlencode "key=sample_string" --data-binary #sample_file.json
but it seems do not work as expected: key=sample_string and sample_file.json content are not send at all.
A couple of things here;
Your curl request is missing double quotes for the headers. It should rather be:
curl www.website.org --request PUT -H "Content-Type: application/json" \
--data-urlencode "key=sample_string" --data-binary #sample_file.json
Your content-type is application/json which I hope is not "binary", so you should rather be using an appropriate type.
In any case, you should be able to find the submitted values using a simple php script as follows:
$putfp = fopen('php://input', 'r');
$putdata = '';
while($data = fread($putfp, 1024))
$putdata .= $data;
fclose($putfp);
var_dump($putdata);
echo "---CONTENT_TYPE---\n";
var_dump($_SERVER['CONTENT_TYPE']);

Resources