problem to make a query REST put, a elasticsearch - rest

I want to send data in the format json a elasticsearch but I can not do it
I'm using elasticsearch version 7.0.1 and curl 7.64, I'm on windows 10
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}
'
i have this error messages :
{
"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported", "status" : 406
}
curl: (6) Could not resolve host: application
curl: (3) URL using bad/illegal format or missing URL

On Windows, you need to use double quotes everywhere, not single quotes:
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H "Content-Type: application/json" -d "{ \"name\": \"John Doe\" }"

Related

Where do I find the paths value to use with the Xray REST API - Artifact Summary call?

The XRay Rest API Artifact Summary "provides details about any artifact specified by path identifiers or checksum." The documentation ( https://www.jfrog.com/confluence/display/JFROG/Xray+REST+API#XrayRESTAPI-ArtifactSummary ) offers this template:
{
"checksums": [
""
],
"paths": [
""
]
}
This works if I use the SHA256 checksum of the artifact I'm interested in, however I can't determine the syntax to use with the paths tag.
From our Artifactory UI, the artifact ( a docker image's manifest.json file) has this repository Path: REPO_NAME/os/ubuntu20/ubuntu20/20.04.5/manifest.json
Using the SHA256 value for the manifest.json file in the call correctly returns the Artifact Summary json:
curl -ufoo:bar -H "Content-Type: application/json" -d '{"checksums" : ["<SHA256_Artifact_1>"]}' -X POST https://localhost/xray/api/v1/summary/artifact
Unforutnately, using any combination of values in the 'paths' field returns a not indexed/cached in Xray.
API calls:
curl -ufoo:bar -H "Content-Type: application/json" -d '{"paths" : ["REPO_NAME/os/ubuntu20/ubuntu20/20.04.5/manifest.json"]}' -X POST https://localhost/xray/api/v1/summary/artifact
curl -ufoo:bar -H "Content-Type: application/json" -d '{"paths" : ["os/ubuntu20/ubuntu20/20.04.5/manifest.json"]}' -X POST https://localhost/xray/api/v1/summary/artifact
curl -ufoo:bar -H "Content-Type: application/json" -d '{"paths" : ["os/ubuntu20/ubuntu20/20.04.5/manifest.json"], "repo" : "REPO_NAME"}' -X POST https://localhost/xray/api/v1/summary/artifact
curl -ufoo:bar -H "Content-Type: application/json" -d '{"paths" : ["os/ubuntu20/ubuntu20/20.04.5/manifest.json"]}' -X POST https://localhost/xray/api/v1/summary/artifact?repo=REPO_NAME
Returns string:
{"artifacts":[],"errors":[{"identifier":"REPO_NAME/os/ubuntu20/ubuntu20/20.04.5/manifest.json","error":"Artifact doesn't exist or not indexed/cached in Xray"}]}
I'm looking to use the Artifact path (which is known) to request the Artifactory Summary JSON. Any suggestions on how this is to be formatted?

mongodb atlas api Create Legacy Backup Restore Job

I have two clusters A and B in project C.
A uses legacy backup and B uses cloud backup.
I am trying to use mongodb atlas API to create a restore job for A to restore to B.
My cli command look like this:
curl --user "<public key>:<private key>" --digest \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--request POST "https://cloud.mongodb.com/api/atlas/v1.0/groups/< C 's project id>/clusters/<A's cluster name>/restoreJobs?pretty=true" \
--data '
{
"delivery" : {
"methodName" : "AUTOMATED_RESTORE",
"targetGroupId" : "< C 's project id>",
"targetClusterId" : "<B's cluster name>"
},
"snapshotId": "XXXXX"
}'
I got error like this:
{
"detail" : "Received JSON for the delivery attribute does not match expected format.",
"error" : 400,
"errorCode" : "INVALID_JSON_ATTRIBUTE",
"parameters" : [ "delivery" ],
"reason" : "Bad Request"
}%
this is the reference: https://docs.atlas.mongodb.com/reference/api/legacy-backup/restore/create-one-restore-job/
can anyone help with this command? what is incorrect in it?
more details:
I run from UI that A can restore to B. it doesn't matter they have different backup settings.
from reference example, it said using , its incorrect and output error can't recognize id so I used instead.
someone else also has a similar error I had because of syntax error: https://jira.mongodb.org/browse/DOCS-12396, but I cant find there is an error in my command.
Hi I think you are using wrong syntax.
Refer: https://docs.atlas.mongodb.com/reference/api/cloud-backup/restore/create-one-restore-job/
curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest --include \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--request POST "https://cloud.mongodb.com/api/atlas/v1.0/groups/{PROJECT-ID}/clusters/{SOURCE-CLUSTER-NAME}/backup/restoreJobs" \
--data '{
"snapshotId" : "{SNAPSHOT-ID}",
"deliveryType" : "automated",
"targetClusterName" : "{TARGET-CLUSTER-NAME}",
"targetGroupId" : "{TARGET-PROJECT-ID}"
}'

Create topic in Message-Hub via curl command

I am trying to create a topic in Message-Hub using a curl command.
I followed this yaml: https://github.com/ibm-messaging/message-hub-docs/blob/master/kafka-administration-api/KafkaTopicManagement.yaml
I'm getting HTTP 405 Method Not Allowed when running the following:
curl -X POST --tlsv1.2 -vk -H "Content-Type: application/vnd.kafka.binary.v1+json" -H "X-Auth-Token: apikey from the environment variable of my app" https://kafka-rest-prod01.messagehub.services.us-south.bluemix.net/topics -d "{ \"TopicCreateParam\" { \"name\": \"my.test\" }}"
Thanks for any help.
#jd76 three problems here:
your URL is missing the /admin/ path
your content-type should just be plain json
TopicCreateParam is just the name of the type in the swagger yml.
Try:
curl -H "Content-Type: application/json" -H "X-Auth-Token: apikey from the environment variable of my app" -d "{ \"name\": \"my.test\" }" https://kafka-rest-prod01.messagehub.services.us-south.bluemix.net/admin/topics

list servers OrientDB 2.2. via http rest

i try to get servers status of distributed version of OrientDB via http rest :
curl --user admin:admin --header "Accept: text/csv" -d "list servers " "http://localhost:2480/command/GratefulDeadConcerts/sql"
doesnt works :
{
"errors": [
{
"code": 500,
"reason": 500,
"content": "com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException: Cannot find a command executor for the command request: sql.list servers\u000d\u000a\u0009DB name=\"GratefulDeadConcerts\""
}
you're sending a list servers command to the sql interpreter while that's not a sql command but a console one.
UPDATE
you can use this
curl --user root:root --header "Accept: text/csv" -d "HA STATUS -servers -output=text" "http://localhost:2480/command/GratefulDeadConcerts/sql"
Run this command to get the results as JSON that contains all servers (nodes) with detailed status and info per server:
curl -X POST --user {{user}}:{{password}} --header "Accept: application/json" \
-d "HA STATUS -servers -db" "{{orientdb-url}}:2480/command/{{database-name}}/sql"

View individual deployment status in Wildfly with curl/API

I'm very new to Wildfly but I need to set up automated monitoring of individual deployment status via the API.
In the same way that I can view the server state with curl, eg:
curl --insecure --digest 'https://admin:password#localhost:9993/management' --header "Content-Type: application/json" -d '{"operation":"read-attribute","name":"server-state","json.pretty":1}'
Will return:
{
"outcome" => "success",
"result" => "running"
}
In the same way the from the jboss-cli, I issue:
:read-attribute(name=server-state)
And get the same result.
So, from the CLI, if I issue the following command to get the status of a specific deployment:
/deployment=bob :read-attribute(name=status)
I get the following result:
{
"outcome" => "success",
"result" => "OK"
}
But I can't work out what curl command will give me that result. I've read through a tonne of documentation and either it doesn't exist or I'm looking in the wrong spot. I've tried:
curl --insecure --digest 'https://password#localhost:9993/management' --header "Content-Type: application/json" -d '{"deployment":"bob","operation":"read-attribute","name":"status","json.pretty":1}'
but that didn't work. Any ideas?
Thanks,
Mark J.
You need to add an array for the address attribute and move the "deployment":"bob" in the array.
curl --insecure --digest 'https://password#localhost:9993/management' --header "Content-Type: application/json" -d '{"operation":"read-attribute", "address":[{"deployment":"bob"}],"name":"status","json.pretty":1}'
The address is a name/value pair object for the path the attribute you want to read. For example if you wanted to see the all the handlers associated with the root logger you could execute the following.
curl --insecure --digest 'https://password#localhost:9993/management' --header "Content-Type: application/json" -d '{"operation":"read-attribute","address":[{"subsystem":"logging"},{"root-logger":"ROOT"}],"name":"handlers","json.pretty":1}