According to the StarGate documentation, this is how a CURL command should look like:
% curl -H "Content-Type: text/xml" --data '[...]' http://localhost:8000/test/testrow/test:testcolumn
This is what I'm trying:
% curl -X POST -H "Accept: text/xml" --data '[<CellSet><Row key="cm93MQ=="><Cell column="dGl0bGU6YQ==">d29ya2Vk</Cell></Row></CellSet>]' http://localhost:8080/test/row1/title
Keep getting HTTP 415, Unsupported Media Type.. any ideas what I'm missing there?
Your current curl options specify you'd like XML output, and curl is assuming you are posting url-encoded form data (and specifying the wrong Content-Type in the HTTP headers).
Amend your -H "Accept: text/xml" to -H "Content-Type: text/xml" and you should be good
Related
Hello,
I'm currently using grafana to visualize data from InfluxDB, and would like to use a hyperlink in form of a HTTP request from a dashboard to insert data into the database.
Is something like this possible?
This is possible.
In InfluxDB v1.X, you could do:
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
In InfluxDB v2.X, you could do:
curl --request POST \
"http://localhost:8086/api/v2/write?
org=YOUR_ORG&bucket=YOUR_BUCKET&precision=ns" \
--header "Authorization: Token YOUR_API_TOKEN" \
--header "Content-Type: text/plain; charset=utf-8" \
--header "Accept: application/json" \
--data-binary '
airSensors,sensor_id=TLM0201 temperature=73.97038159354763,humidity=35.23103248356096,co=0.48445310567793615 1630424257000000000
airSensors,sensor_id=TLM0202 temperature=75.30007505999716,humidity=35.651929918691714,co=0.5141876544505826 1630424257000000000
'
See more details here and there.
I looked at all previous answers on this subject but just can't get my POST request to work in cURL windows although it works perfectly in PostMan. I exported the code using </> and tried several combinations of export parameters... any help would greatly appreciated!
Here's my cURL code:
curl -L -X POST "https://timingserver.net/api/bridge/generic" -H "cache-control: no-cache" -H "connection: close" -H "content-type: application/json" --data-raw "{
\"username\":\"myusername\",
\"password\":\"mypassword\",
\"event\":\"demo\",
\"checkpoint\":12,
\"detections\":[{\"bib\":100, \"dt\":\"2022-01-12T13:09:23.045\"},
{\"bib\":101, \"dt\":\"2022-01-12T13:09:23.045\"},
{\"bib\":102, \"dt\":\"2022-01-12T13:09:23.045\"},
{\"bib\":199, \"dt\":\"2022-01-12T13:10:23.045\"}]
}"
Getting several errors in the same execution: Code 400, not recognized as an internal or external command... cannot find the path specified...
You need to remove the linebreaks:
curl -L -X POST "https://timingserver.net/api/bridge/generic" -H "cache-control: no-cache" -H "connection: close" -H "content-type: application/json" --data-raw "{ \"username\":\"myusername\", \"password\":\"mypassword\", \"event\":\"demo\", \"checkpoint\":12, \"detections\":[{\"bib\":100, \"dt\":\"2022-01-12T13:09:23.045\"}, {\"bib\":101, \"dt\":\"2022-01-12T13:09:23.045\"}, {\"bib\":102, \"dt\":\"2022-01-12T13:09:23.045\"}, {\"bib\":199, \"dt\":\"2022-01-12T13:10:23.045\"}] }"
To generate curl output for windows using postman click on settings next to curl code section and change line continuation character to ^ and quote double and shown in the image. This should generate output for windows. You can also change the output to single or multiline.
I'm trying to create a Jelastic Manifest with a cURL command inside it. When I import it, it gives me an error but unfortunately I have no access to the console (disabled by the provider).
The command is the following :
curl -X POST <my_url> -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d "{}"
Some additionnal information :
The URL is correct 100%
The token does not contain any special characters : Only upper/lowercase characters and numbers
The command is run successfully from the command line
If I remove the first -H parameter, I can import my manifest. Same if I remove the second -H parameter and keep the first one
My guess is that, somehow, having two -H is not considered as valid but I don't know why. Any ideas ?
EDIT : A screenshot of the error shown on the platform
The "two -H parameters" wasn't a root cause in your question.
The thing is that the YAML gets the data you sent as a key/value array (dictionary).
In your example it would be:
curl -s -X POST https://test.com -H "Content-Type - as a key,
and
application/json" -H "Authorization: Bearer xx" -d "{\"Key\":\"Value\"}" - as a value.
If you need an array of strings the YAML may be as this
cmd [cp]:
- 'curl -s -X POST https://test.com -H "Content-Type: application/json" -H "Authorization: Bearer xx" -d "{\"Key\":\"Value\"}"'
If you need a multi-line string it should look like this
cmd [cp]: |
curl -s -X POST https://test.com -H "Content-Type: application/json" -H "Authorization: Bearer xx" -d "{\"Key\":\"Value\"}"
I am having a EmailRepository which queries for a person like follows
findByPerson(Person person);
The spring-data-rest /search resource list the following href
http://localhost:8080/emailAddresses{?person}
How to make a curl command for the above search url in GET method? Also if the person does not exists, I need to throw "PersonNotFoundException".
I am using org.springframework.boot:spring-boot-starter-data-rest:jar:1.3.3.RELEASE
Try the below curl commands -
if you are using path param -
curl -i -X GET -H "Content-Type: application/json" -H "Cache-Control: no-cache" -k "http://localhost:8080/emailAddresses/person"
if you are using query param -
curl -i -X GET -H "Content-Type: application/json" -H "Cache-Control: no-cache" -k "http://localhost:8080/emailAddresses?person=aaa"
Is it possible to automate the configuration of an index pattern in kibana? Either via some settings file or perhaps a rest api. After installation it's possible to do it manually.
Kibana 5.x exposes such an API to manage index patterns.
To create index pattern one can issue below command to kibana access url (just edit the kibana endpoint, index-name and timestamp variables to match your needs):
curl <kibana-endpoint>/es_admin/.kibana/index-pattern/<index-name>/_create\
-H "Content-Type: application/json"\
-H "Accept: application/json, text/plain, */*"\
-H "kbn-xsrf: <index-name>"\
--data-binary '{"title":"${<index-name>}","timeFieldName":"<timestamp-field>"}' -w "\n"
For instance if kibana is under localhost:5601 and index-name is alert (alert_time is timestamp field) then command:
curl localhost:5601/es_admin/.kibana/index-pattern/alert/_create\
-H "Content-Type: application/json"\
-H "Accept: application/json, text/plain, */*"\
-H "kbn-xsrf: alert"\
--data-binary '{"title":"alert","timeFieldName":"alert_time"}' -w "\n"
Similarly, one can define default index pattern using below API for the example:
curl localhost:5601/api/kibana/settings/defaultIndex\
-H "Content-Type: application/json"\
-H "Accept: application/json, text/plain, */*"\
-H "kbn-xsrf: alert"\
-H "Connection: keep-alive"\
--data-binary "{\"value\":\"alert\"}" -w "\n"
At present this is not possible. There is an issue at the Kibana github repo which schedules an Index pattern creation API for the 4.5.0 release.
https://github.com/elastic/kibana/issues/3709