I want to create an index pattern using Opensearch API. I tried to replicate what could be made graphically in the following image window, using as index pattern name cwl-* and then as time field #timestamp.
My domain has OpenSearch 1.2 installed.
Using curl (directly modifiend the command in kibana doc):
curl -u '****:*****' -X POST "https://******.eu-central-1.es.amazonaws.com/api/index_patterns/index_pattern" -H 'osd-xsrf: true' -H 'Content-Type: application/json' -d'
{
"index_pattern": {
"title": "cwl-*",
"timeFieldName": "#timestamp"
}
}'
but I receive
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [api] as the final mapping would have more than 1 type: [_doc, index_patterns]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [api] as the final mapping would have more than 1 type: [_doc, index_patterns]"},"status":400}
curl -u '****:*****' -X POST "https://******.eu-central-1.es.amazonaws.com/api/index_patterns/cwl-*" -H 'osd-xsrf: true' -H 'Content-Type: application/json' -d'
{
"index_pattern": {
"title": "cwl-*",
"timeFieldName": "#timestamp"
}
}'
change api/index_patterns/index_pattern to api/index_patterns/cwl-* and try again?
It worked for me in OpenSearch 1.3 when I added an ID in the URI and used saved_objects instead of index_patterns.
So your cURL-request should work when looking like this.
curl -u '****:*****' -X POST "https://<opensearch-dashboards-host>.eu-central-1.es.amazonaws.com/api/saved_objects/index-pattern/<ID>"
-H 'osd-xsrf: true'
-H 'Content-Type: application/json'
-d
'{
"index_pattern": {
"title": "cwl-*",
"timeFieldName": "#timestamp"
}
}'
Related
Is there an easy way to get all the statistics on the pillars on the Zenon Network?
You can use curl on the command line and access the method: embedded.pillar.getAll (https://testnet.znn.space/#!api.md)
I passed the output to the command jq so it can be easily read.
curl -X POST http://127.0.0.1:35997 -H 'Content-Type:
application/json' -d '{"jsonrpc": "2.0", "id": 20, "method":
"embedded.pillar.getAll","params": [0, 299]}' | jq
This will give you the output of:
I encountered a problem while developing here
This curl command is something I have n’t encountered before and it has n’t been resolved for a long time
Please help me
How to convert to postman format, my import using postman cannot be recognized correctly
code:
curl -v -X POST https://api.sandbox.paypal.com/v1/customer/disputes/PP-D-27803/provide-evidence \
-H "Content-Type: multipart/related; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" \
-H "Authorization: Bearer Access-Token" \
-F 'input={
"evidences": [
{
"evidence_type": "PROOF_OF_FULFILLMENT",
"evidence_info": {
"tracking_info": [
{
"carrier_name": "FEDEX",
"tracking_number": "122533485"
}
]
},
"notes": "Test"
}
]
};type=application/json' \
-F 'file1=#NewDoc.pdf'
我自己解决了
看图片
目前只能使用curl成功 postman python requests php 都没有成功
主要还是后面这个#符号
enter image description here
this:
curl "http://localhost:8000/v1/post" \
-H 'Content-Type: application/json' \
-H 'Accept-Encoding: gzip' \
-d $'{
"url": "/my-test-url"
}'
with this:
class PostView(APIView):
def get(self, request, format=None):
print(request.data['url'])
result = {}
return Response(result)
crashes on the print line...
KeyError: 'url'
However, changing the GET into a POST:
curl -X "POST" "http://localhost:8000/v1/post" \
-H 'Content-Type: application/json' \
-H 'Accept-Encoding: gzip' \
-d $'{
"url": "/my-test-url"
}'
class PostView(APIView):
def post(self, request, format=None):
print(request.data['url'])
result = {}
return Response(result)
will print it fine.
/my-test-url
[26/Nov/2019 22:00:42] "POST /v1/post HTTP/1.1" 200 2
This causes me to believe either Django can't handle GET request body payload and that I must use URL parameters instead with GET --- or that I'm missing something.
What am I doing wrong here?
GET requests have no body, that's why data is empty.
If you wanted to pass something using a GET request you would need to use querystring params (eg: http://localhost:8000/v1/post?url=myurl), then you can get them back using request.query_params rather than request.data (eg: request.query_params['url']).
Take a look to the DRF Request Parsing documentation for further details.
Can you try this:
curl -X GET http://localhost:8000/v1/post -H 'Content-Type: application/json' -H 'Accept-Encoding: gzip' -d '{"url": "/my-test-url"}'
I have already trained my data set in Google auto ml. Now I want to pass a CSV with text items to predict its labels. Not sure on how to proceed
Have passed 17k text items with labels.
Have seen rest API & python codes to execute.
export GOOGLE_APPLICATION_CREDENTIALS=key-file-path
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json" \ https://automl.googleapis.com/v1beta1/projects/ticket-classification-poc/locations/us-central1/models/TCN8669499774734365168:predict \ -d '{ "payload" : { "textSnippet": { "content": "YOUR TEXT HERE", "mime_type": "text/plain" }, } }' Output : Need to pass future text items in bulk for prediction
You need to have a loop to go through all the CSV items programatically and send one by one.
I am trying to send a request to aws elasticsearch with aws-es-curl:
aws-es-curl https://myhost.es.amazonaws.com/my-index/_search?pretty -H 'Content-Type: application/json' -d'{"query":{"match_all":{}},"size": "100","index":"my-index", "_source": {"excludes": ["attachment.*","data"], "includes": "owner"}}'
But this returns me all fields. Also I size parameter is also not recognized :( Why this happens? How pass those parameters to es?
ES version is 5.3
Source variants are here
Try to pipe the content of your query into the curl command:
echo '{"query":{"match_all":{}},"size": "100", "_source": {"excludes": ["attachment.*","data"], "includes": "owner"}}' | aws-es-curl -X POST https://myhost.es.amazonaws.com/my-index/_search