Elastic Search is not working - elasticsearch

When I am giving request to Elastic search my post and put is not working
My request
POST bird/admin/1
{
"id":"1",
"ity":"BSP"
}
It should give success
But, getting error
{
"error": "Content-Type header [application/x-www-form-urlencoded; charset=UTF-8] is not supported",
"status": 406
}

You should use application/json content type.
If you are using curl, add -H 'Content-Type: application/json'
https://www.elastic.co/blog/strict-content-type-checking-for-elasticsearch-rest-requests

Related

Invalid Argument on API Call?

I am getting an invalid argument with the following API Call (following https://developers.google.com/nest/device-access/api/doorbell-battery#webrtc):
curl -X POST 'https://smartdevicemanagement.googleapis.com/v1/enterprises/projectID/devices/deviceID:executeCommand' -H 'Content-Type: application/json'
-H 'Authorization: AUTHTOKEN' --data-raw '{
"command" : "sdm.devices.commands.CameraLiveStream.GenerateWebRtcStream",
"params" : {
"offerSdp" : "a=recvonly"
}
}'
Response from server:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
What is the invalid argument?
My impression is that is not a valid offer, and you need to use a web rtc client to create it. See webrtc.org for examples.
"offerSdp" : "a=recvonly" isn't a valid offer, but also you will get that INVALID_ARGUMENT error if you don't end your offer string with a \r\n character.

laptop curl Youtube API v3 request always returns 'Exceeded Quota' error

Every time I attempt to use the following simple bash script command on my Macbook Pro laptop, I get an 'Exceeded Quota' error. I do supply a valid API key and I'm under the impression that I don't need any other tokens because I am only requesting Public information (a simple list of songs).
Bash script:
#!/bin/bash
curl \
'https://youtube.googleapis.com/youtube/v3/search?part=snippet&q=music&type=video&key=[My API key]' \
--header 'Accept: application/json' \
--compressed
Reply:
{
"error": {
"code": 403,
"message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e.",
"errors": [
{
"message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e.",
"domain": "youtube.quota",
"reason": "quotaExceeded"
}
]
}
}
I don't have any quota problems pulling song lists via the YouTube Data API 'list' page:
https://developers.google.com/youtube/v3/docs/search/list

Send request to elastic watcher via curl

ELK 7.X
I am trying to create elastic search watcher with curl using the input file. Something like this
curl -X PUT _watcher/watch/cluster_health_watch --data-binary #inputFile
1) What is the file type to be used ? Most of the data is json, but in "actions" field when sending an email, the email body can be HTML !
2) Is there any way that the HTML in the body can be referred from an external file, such that input file can be json ?
Just escaped the double quotes in the html string by adding "\".
Ex:-
<h3 style=\"color:red\"></h3>
"actions": {
"send_email": {
"email": {
"to": "xxxx#gmail.com",
"subject": "My Subject",
"body": {
"html": "<h3 style=\"color:red\"> There was a problem</h3>"
}
}
}
}
curl -X PUT _watcher/watch/cluster_health_watch -H 'Content-Type: application/json' --data-binary #inputFile.json

I am getting this error in elasticsearch

{
"error":"Content-Type header [application/x-www-form-urlencoded] is not supported",
"status":406
}
Though I used header Content-Type
Here is the the command I used for indexing a customer document for a customer index:
curl -XPUT localhost:9200/customer/doc/1 -H 'Content-Type:application/json' -d '{"name":"abcd"}'

Spotify Web API Malformed json error when using /me/player/play endpoint

I want to use the Spotify Web API to play a specfic song on one of my devices.
In the dev article it says to use a JSON Array. I tried doing it like this:
curl -X PUT "https://api.spotify.com/v1/me/player/play"
-H "Authorizatin: Bearer {authToken}"
-H "Content-Type: application/x-www-form-urlencoded"
--data "json={\"uris\": [\"spotify:track:0i2QIV9Lku6x5zQkN7DZpn\"]}"
However, I am getting a 400 error code:
{
"error" : {
"status" : 400,
"message" : "Malformed json"
}
If anyone could tell me how I have to send this request, that'd be great.

Resources