I'm writing a bash script using cURL to call an API. I'm generating some part of the contents transforming strings coming out from other sources.
From the db the spaces are replaced with "_SPACE_" string for application reasons.
I'm replacing it using
ITEM=${M//_SPACE_/ }
and then I call cURL as follow:
curl ... --data '{"field": "'$ITEM'"}' ...
Running the script it returns an exception on curl execution
curl: (3) [globbing] unmatched close brace/bracket in column 21
org.codehaus.jackson.JsonParseException: Unexpected end-of-input in VALUE_STRING
at [Source: org.apache.catalina.connector.CoyoteInputStream#185ff06c; line: 4, column: 139]
The exception
org.codehaus.jackson.JsonParseException: Unexpected end-of-input in VALUE_STRING ...
says that your lib from codehouse is not able to parse the data object which is send via curl. i could imagin that your --data '{"field": "'$ITEM'"}' object fails because of the single quotes '$ITEM'. could u send the complete data object or script ?
Related
I have a standard embedded tomcat REST API application. I would like clients to send zipped JSON bodies using the header Content-Encoding: gzip
Below is an idea of how this might work:
echo '{"field1":"hello","field2":"there"}' > request.json
gzip request.json
curl -u user:password -H "Content-Encoding: gzip" -H 'Content-Type:application/json;charset=utf8' --data-binary #request.json.gz HTTP://localhost:8100/some/path
I noticed (in the docs) support for compressing the response. I enabled this using server.compression.enabled: true.
I get this error (which indicates to me that the binary data is interpreted as a JSON:
JSON parse error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\\r, \\n, \\t) is allowed between tokens; nested exception is com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\\r, \\n, \\t) is allowed between tokens\n at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 2]
How can I tell Spring Boot to uncompress requests with this header?
I guessed server:http2.enabled: true would work, but this does not seem to have an effect. Is http2 somehow tied to this feature?
I'm trying to insert a file to influx through shell script using write API. Inconsistently data is not getting inserted. I get 'Invalid Boolean' response whenever its failing to insert to influx.
Kindly help me in identifying where i'm doing the mistake
Here is my code to write to influx
curl -s -X POST "http://influxdb:8186/write?db=mydb" --data-binary #data.txt
I get below json response with an error very inconsistently.
I'm generating the data.txt file with after some calculation. Below is the screenshot of the file.
{"error":"unable to parse 'databackupstatus1,env=engg-az-dev2 tenant=dataplatform snapshot_name=engg-az-dev2-dataplatform-2019-07-08_12-43-59 state=Started backup_status=Not-Applicable': invalid boolean\nunable to parse 'databackupstatus1,env=engg-az-dev2 tenant=dataplatform snapshot_name=engg-az-dev2-dataplatform-2019-07-08_12-43-59 state=Completed backup_status=\"SUCCESS\"': invalid boolean"}
Note : The same data above had got inserted multiple times
i've the following example dynamic generated url for GET request
http://api.jwplatform.com/v1/videos/create?api_format=json&api_key=dgfgfg&api_nonce=554566&api_timestamp=1500296525&custom.videoId=905581&description=تقليد بداية العام&downloadurl=http://media.com/media/mymedia.mp4&sourceformat=mp4&sourcetype=url&sourceurl=http://media.com/media/mymedia.mp4&title=الغطس بالمياه الباردة.. تقليد بداية العام&api_signature=5cd337198ead0768975610a135e2
which is include the following vars
api_key=
api_nonce=
api_timestamp=
custom.videoId=
description=
downloadurl=
sourceurl=
title=
api_signature=
sourceformat=mp4
sourcetype=url
i;m tring to get send curl GET command and get the response back i always failed for 2 reason ,
the urls in the request should be encoded utf8
and the 2nd one the i always get curl: (6) Couldn't resolve host for
each vars like its not taking the url as one url and break it into
different calls for example
curl: (6) Couldn't resolve host 'بداية'
Input domain encoded as `ANSI_X3.4-1968'
Failed to convert العام&downloadurl=http: to ACE; System iconv failed
getaddrinfo(3) failed for العام&downloadurl=http::80
curl -X -G -v -H "Content: agent-type: application/x-www-form-urlencoded" http://api.jwplatform.com/v1/videos/create?api_format=json&{vars}
and tips how i can reach this and construct the curl command in the right format
I'm trying to use the _analyze api with text that looks like this:
--- some -- text ---
This request works as expected:
curl localhost:9200/my_index/_analyze -d '--'
{"tokens":[]}
However, this one fails:
curl localhost:9200/medical_documents/_analyze -d '---'
---
error:
root_cause:
- type: "illegal_argument_exception"
reason: "Malforrmed content, must start with an object"
type: "illegal_argument_exception"
reason: "Malforrmed content, must start with an object"
status: 400
Considering the formatting of the response, i assume that elasticsearch tried to parse the request as yaml and failed.
If that is the case, how can i disable yml parsing, or _analyze a text that starts with --- ?
The problem is not the yaml parser. The problem is that you are trying to create a type.
The following is incorrect(will give you Malforrmed content, must start with an object error)
curl localhost:9200/my_index/medical_documents/_analyze -d '---'
This will give you no error, but is incorrect. Because it will tell elastic to create a new type.
curl localhost:9200/my_index/medical_documents/_analyze -d '{"analyzer" : "standard","text" : "this is a test"}'
Analyzers are created Index level. verify with:
curl -XGET 'localhost:9200/my_index/_settings'<br/>
So the proper way is:
curl -XGET 'localhost:9200/my_index/_analyze' -d '{"analyzer" : "your_analyzer_name","text" : "----"}'
Previously need to create the analyzer.
I'm trying to get this tutorial to work in CMD and Windows Powershell (Windows 7 64): http://www.elasticsearchtutorial.com/elasticsearch-in-5-minutes.html
The first command already doesn't work in CMD:
curl -XPUT 'http://localhost:9200/blog/user/dilbert' -d '{ "name" : "Dilbert Brown" }'
I get the following error message:
curl: (1) Protocol 'http not supported or disabled in libcurl
curl: (6) Could not resolve host: name
curl: (7) Failed to connect to port 80: Connection refused
curl: (6) Could not resolve host: Dilbert Brown
curl: (3) [globbing] unmatched close brace/bracket in column 1
In Windows Powershell I get:
{"error":"MapperParsingException[failed to parse]; nested: JsonParseException[Unrecognized token 'Dilbert': was expecting ('true', 'false' or 'null')\n at [Source: [B#132b73b; line: 1, column: 33]]; ","status":400}curl: (3) [globbing] unmatched close brace/bracket in column 7
The same command works without any problems in Cygwin. How would I have to write the command to make it work in CMD and Windows Powershell?
In PowerShell, the command is being called correctly, from a parsing perspective.
In cmd.exe, the single quotes are not valid. You will need to use double quotes to surround values.
curl -XPUT "http://localhost:9200/blog/user/dilbert" -d "{ \"name\" : \"Dilbert Brown\" }"