Tag Archives: curl

How to Solve Curl pass large JSON files Error

Solutions to errors in curl passing large JSON files

Next, the shell first obtains the token, and then sends the JSON file to the server with the token,   After hours of normal JSON files, the following shell can run normally.

#!/bin/bash
#
access_res=$(curl "http://192.168.1.1:30100/api/v1/ability_sub/external/getToken?appId=d53e9b4083a8577e31dae685305fd032&secret=27766999
0d60d4616a8ae1fd9d6fc114")

access_token=$(echo $access_res |cut -d":" -f6 |cut -d"}" -f1|sed s/\"//g)

accress_url='curl -i -X POST -H "Content-Type:application/json" -d @/opt/accesstoken/test.json http://192.168.1.1:30202/app-l59q59yp3po2
7l-store/quality/faultOrderQ?'${access_token}

echo $accress_url
$accress_url

When using curl post data, if the post data is greater than 1024 bytes, curl will not directly initiate the post request. But in two steps.

1. Send a request. The header contains an expect: 100 continue to ask whether the server is willing to accept data

2. After receiving the 100 continue response returned by the server, post the data to the server.

By default, the server is enabled to receive JSON. In this case, the query before sending is removed and – H “expect:” is added, as follows:

accress_url='curl -i -X POST -H "Expect:" -H "Content-Type:application/json" -d @/opt/accesstoken/test.json http://192.168.1.1:30202/app-l59q59yp3po2 7l-store/quality/faultOrderQ?'${access_toke

In this way, you can add scheduled tasks

Possible reasons for elasticsearch using curl to guide datagram 400

With multi-dimensional model as the core, let the factory digital transformation and upgrading “within reach”>>>

curl -H 'Content-Type: application/x-ndjson'  -s -XPOST 10.0.3.73:9200/yyzj2019-04/trans/_bulk?pretty --data-binary @../test_6000.txt

Error report

 1 {
 2   "error" : {
 3     "root_cause" : [ {
 4       "type" : "parse_exception",
 5       "reason" : "Failed to derive xcontent"
 6     } ],
 7     "type" : "parse_exception",
 8     "reason" : "Failed to derive xcontent"
 9   },
10   "status" : 400
11 }

Possible causes:

1. Carefully check the IP, port and the file name path after @ in the command

2. Check the encoding format of data file TXT, use UTF-8

3。。。

Follow up supplement