I've looked into a lot of topics but nothing helped me in solving my issue.
I'm running the below .sh and .txt files on a Windows OS through Git Bash with
./Test.sh
My script:
#!/bin/sh
File="urls.txt"
Lines=$(cat $File)
for line in $Lines
do
curl -k -v --location -X POST \
--header 'Content-Type: application/json' \
--data-raw '' \
$line; \
sleep 5s
done
Inside of my urls.txt are two urls which reach a locally hosted ASP.NET Core application.
https://localhost:44321/single/264490
https://localhost:44321/single/306533
My issue is that I'm only able to send the second url. Of I have 5,10,15 urls I only send the last one
When I echo the curl I get
curl -k -v --location -X POST --header Content-Type: application/json
--data-raw https://localhost:44321/single/264490
curl -k -v --location -X POST --header Content-Type: application/json
--data-raw https://localhost:44321/single/306533
I am using a three second delay as I thought perhaps I cannot process them in parallel, which has not been the case usually.
In my verbose curl output when I try to process the file I receive:
Note: Unnecessary use of -X or --request, POST is already inferred.
Closing connection -1 curl: (3) URL using bad/illegal format or missing URL Note: Unnecessary use of -X or --request, POST is already
inferred. % Total % Received % Xferd Average Speed Time
Time Time Current
Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:--
--:--:-- 0* Trying ::1:44321...
TCP_NODELAY set
Connected to localhost (::1) port 44321 (#0)
ALPN, offering h2
ALPN, offering http/1.1
successfully set certificate verify locations:
CAfile: C:/Users/kmilchev/AppData/Local/Programs/Git/mingw64/ssl/certs/ca-bundle.crt
CApath: none } [5 bytes data]
TLSv1.3 (OUT), TLS handshake, Client hello (1): } [512 bytes data]
TLSv1.3 (IN), TLS handshake, Server hello (2): { [94 bytes data]
TLSv1.2 (IN), TLS handshake, Certificate (11): { [762 bytes data]
TLSv1.2 (IN), TLS handshake, Server key exchange (12): { [365 bytes data]
TLSv1.2 (IN), TLS handshake, Server finished (14): { [4 bytes data]
TLSv1.2 (OUT), TLS handshake, Client key exchange (16): } [102 bytes data]
TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): } [1 bytes data]
TLSv1.2 (OUT), TLS handshake, Finished (20): } [16 bytes data]
TLSv1.2 (IN), TLS handshake, Finished (20): { [16 bytes data]
SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
ALPN, server accepted to use h2
Server certificate:
subject: CN=localhost
start date: Sep 26 08:49:41 2019 GMT
expire date: Sep 26 00:00:00 2024 GMT
issuer: CN=localhost
SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
Using HTTP2, server supports multi-use
Connection state changed (HTTP/2 confirmed)
Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 } [5 bytes data]
Using Stream ID: 1 (easy handle 0x253b150) } [5 bytes data]
POST /single/306533 HTTP/2
Host: localhost:44321
User-Agent: curl/7.65.3
Accept: /
Content-Type: application/json
Content-Length: 0
{ [5 bytes data]
Connection state changed (MAX_CONCURRENT_STREAMS == 100)! } [5 bytes data] 0 0 0 0 0 0 0 0 --:--:-- 0:00:01
--:--:-- 0< HTTP/2 409 < content-type: application/problem+json; charset=utf-8 < server: Kestrel < x-powered-by: ASP.NET < date: Thu,
07 Apr 2022 14:49:43 GMT
HTTP error before end of send, stop sending < { [132 bytes data] 100 132 0 132 0 0 69 0 --:--:-- 0:00:01 --:--:--
69{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.8","title":"Conflict","status":409,"traceId":"|2c38adc9-44ba9a4c97bbc819."}
Connection #0 to host localhost left intact
For some reason it's not able to recognize the first URL even though in the echo output I can confirm it's correct and it's the same as the second one.
I've also tried an xargs delimiter, same result.
#!/bin/sh
# cat "url.txt" \
# | xargs -P 2 -d '\n' -I % \
# curl -L 1 -X POST \
# --header "Content-Type: application/json" \
# --header "Accept: application/json" \
# --header "Content-Length: 0" \
# "http://localhost:58600/single/%";
Any advice?
Related
I am trying to do buy/sell orders after some computation in the unix-BASH environment by application of www.api.coinex.com data. Therefore, I wrote s simple BASH code to put a market order for DOGEUSDT.
I use the following official guidelines:
API Invocation Instruction
Place Market Order
-I use VPN IN MINT 20. Linux.
-The codes to get data work well, but have problems with POST data.
#!/bin/bash
#A code to put a market order in the www.coinex.com exchange pairs
#My Access ID in www.coinex.com
access_id="xxxx"
#My secrect Key in www.coinex.com
secret_key="xxxx"
#Request Url
get_url="https://api.coinex.com/v1/order/market"
#Any Amount
amount="100.0"
#Any pair in the Market
marketpair="DOGEUSDT"
#buy or sell
market_type="sell"
#the market price
price="0.041"
#Get servertime, Tonce is a timestamp with a positive Interger that represents the number of milliseconds from Unix epoch to the current time. Error between tonce and server time can not exceed plus or minus 60s
tonce=`curl -X GET https://api.coinex.com/v1/market/ticker/all | jq .data.date`
#authorization code using 32-bit MD5 Algorithm Signature
authorization=`echo -n 'access_id='$access_id'&amount='$amount'&market='$marketpair'&tonce='$tonce'&type='$market_type'&secret_key='$secret_key''|md5sum`
#Convert authorization to UPPERCASE
authorization1=`echo ${authorization^^}`
#Place market order
curl -v -H "authorization:'$authorization1'" -H "Content-Type: application/json" -d '{"access_id":"'$access_id'", "amount": "'$amount'","market":"'$market'", "tonce": "'$tonce'", "type": "'$market_type'"}' -X -POST "'$get_url'"
I got following error:
* Could not resolve host: 'https
* Closing connection 0
curl: (6) Could not resolve host: 'https
Edition
I got the following error after running the latest proposals in the comments.
` `++ curl -v -H 'authorization: 5EB8EFD237AC301BB854D32407C39AF8 -' -H 'Content-Type: application/json' -d '{
"access_id": "03391998195A4A3EAD0D6C59336CF1D1",
"amount": "0.1",
"market": "ARUSDT",
"tonce": "1636216102004",
"type": "sell"
}' --url https://api.coinex.com/v1/order/market
* Trying 104.18.30.180:443...
* TCP_NODELAY set
* Connected to api.coinex.com (104.18.30.180) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=US; ST=California; L=San Francisco; O=Cloudflare, Inc.; CN=coinex.com
* start date: Nov 1 00:00:00 2021 GMT
* expire date: Oct 31 23:59:59 2022 GMT
* subjectAltName: host "api.coinex.com" matched cert's "*.coinex.com"
* issuer: C=US; O=Cloudflare, Inc.; CN=Cloudflare Inc ECC CA-3
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x562e9c3c3c80)
> POST /v1/order/market HTTP/2
> Host: api.coinex.com
> user-agent: curl/7.68.0
> accept: */*
> authorization: 5EB8EFD237AC301BB854D32407C39AF8 -
> content-type: application/json
> content-length: 140
>
* We are completely uploaded and fine
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200
< date: Sat, 06 Nov 2021 16:28:24 GMT
< content-type: application/json
< content-length: 54
< cf-cache-status: DYNAMIC
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< server: cloudflare
< cf-ray: 6a9fb1d72a0c6283-OTP
<
* Connection #0 to host api.coinex.com left intact
{"code": 25, "data": {}, "message": "Signature error"} `
`
I propose you format your JSON data with jq tool. It's a better and sure formatter than bash or whatelse.
Your cURL last line became:
# The JSON data format for jq command
# Important: $token are not for bash variables but for jq arguments
# So, DATA_FORMAT must be defined between simple cotes (not double)
declare DATA_FORMAT='{"access_id": $access_id, "amount": $amount, "market": $market, "tonce": $tonce, "type": $market_type}'
# jq call to format JSON data
# The jq arguments in data format will be replaced by bash variable values (in this example, with the same name)
declare DATA_CONTENT=$(jq \
--null-input \
--arg access_id "${access_id}" \
--arg amount "${amount}" \
--arg market "${market}" \
--arg tonce "${tonce}" \
--arg market_type "${market_type}" \
"${DATA_FORMAT}" \
)
# cURL call
curl \
-v \
-H "authorization: $authorization1" \
-H "Content-Type: application/json" \
-d "${DATA_CONTENT}" \
--url "$get_url"
According to the latest reply I received from the www.coinex.com support team, the code must be written in node language, they didn’t mention BASH. It seems BASH is not supported.
Also, I found a python package to connect with spot pairs at www.coinex.com. I traded crypto pairs with this repository successfully.
https://github.com/imanmousaei/coinexpy
Based on Sending Push Notifications Using Command-Line Tools, I set the following shell variables after making a new CSR, App ID, and obtaining a new provider certificate from Apple:
CERTIFICATE_FILE_NAME=/Users/developer/desktop/aps.cer
CERTIFICATE_KEY_FILE_NAME=/Users/developer/desktop/PushChatKey.p12
TOPIC=com.domainname.appname
DEVICE_TOKEN=af59ba83a511f21f343df63ebd1bcd32225878e7d9401a4e933a3caf0cf55a63
APNS_HOST_NAME=api.sandbox.push.apple.com
I input the following terminal command to send a test push notification:
curl -v --header apns-topic: com.domainname.appname --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
This was the resulting terminal output:
curl -v --header apns-topic: com.domainname.appname --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
* Could not resolve host: com.domainname.appname
* Closing connection 0
curl: (6) Could not resolve host: com.domainname.appname
* Could not resolve host: alert
* Closing connection 1
curl: (6) Could not resolve host: alert
* Trying 17.188.138.71...
* TCP_NODELAY set
* Connected to api.sandbox.push.apple.com (17.188.138.71) port 443 (#2)
* ALPN, offering h2
* ALPN, offering http/1.1
Enter PEM pass phrase:
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Request CERT (13):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS handshake, CERT verify (15):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=api.development.push.apple.com; OU=management:idms.group.533599; O=Apple Inc.; ST=California; C=US
* start date: Feb 8 21:41:22 2021 GMT
* expire date: Mar 10 21:41:22 2022 GMT
* subjectAltName: host "api.sandbox.push.apple.com" matched cert's "api.sandbox.push.apple.com"
* issuer: CN=Apple Public Server RSA CA 12 - G1; O=Apple Inc.; ST=California; C=US
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fe70780d600)
> POST /3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1 HTTP/2
> Host: api.sandbox.push.apple.com
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 24
> Content-Type: application/x-www-form-urlencoded
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 1000)!
* We are completely uploaded and fine
< HTTP/2 400
< apns-id: E9EC6D23-7E07-BA0A-B574-F478271AE803
<
* Connection #2 to host api.sandbox.push.apple.com left intact
{"reason":"MissingTopic"}* Closing connection 2
How can I fix this?
The problem is with this part:
--header apns-topic: com.domainname.appname
Please adjust it to:
Note the use of single quotes '' at the beginning and end of the --header argument apns-topic: com.domainname.appname
--header 'apns-topic: com.domainname.appname'
curl -v --header 'apns-topic: com.domainname.appname' --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"test"}}' --http2 https://api.sandbox.push.apple.com/3/device/45822f2c09e0dbdfa6659b08f0b35ab8bda910d29f4abb107dfbf88f323e34f1
I am looking to cut the task number which is highlighted in the output. However, normal grep or sed commands or redirection to text file for getting the desired output is not working. As the curl is writing on the terminal screen, these operations arent working. Please suggest.
vcap#jumpbox-sagdf-staging:~ $ curl -v -s -k 'https://admin:88uudjdjd#10.19.1.1:25555/deployments/concourse/vms?format=full'
* Hostname was NOT found in DNS cache
Trying 10.19.1.1....
Connected to 10.19.1.1 (10.19.1.1) port 25555 (#0)
successfully set certificate verify locations:
CAfile: none
CApath: /etc/ssl/certs
SSLv3, TLS handshake, Client hello (1):
SSLv3, TLS handshake, Server hello (2):
SSLv3, TLS handshake, CERT (11):
SSLv3, TLS handshake, Server key exchange (12):
SSLv3, TLS handshake, Server finished (14):
SSLv3, TLS handshake, Client key exchange (16):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSL connection using ECDHE-RSA-AES128-GCM-SHA256
Server certificate:
subject: CN=director
start date: 2017-06-20 13:19:23 GMT
expire date: 2019-06-20 13:19:23 GMT
issuer: CN=rootCA
SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
Server auth using Basic with user 'admin'
GET /deployments/concourse/vms?format=full HTTP/1.1
Authorization: Basic YWRtaW46OHdId1lEVlIwakJCZ3c=
User-Agent: curl/7.35.0
Host: 10.19.1.1:25555
Accept: /
>
< HTTP/1.1 302 Moved Temporarily
Server nginx is not blacklisted
< Server: nginx
< Date: Fri, 30 Jun 2017 04:07:19 GMT
< Content-Type: text/html;charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< WWW-Authenticate: Basic realm="BOSH Director"
< Location: https://10.19.1.1/tasks/1017317
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
<
Connection #0 to host 10.19.1.1 left intact
Since you want to extract the piece on the right of the right-most slash of the Location: response header, I would use this:
curl -so /dev/null -w "%{redirect_url}\n" $URL | sed 's:.*/::g'
so that with your original URL use case it would look like (I added the -k back in this version):
curl -kso /dev/null -w "%{redirect_url}\n" 'https://admin:88uudjdjd#10.19.1.1:25555/deployments/concourse/vms?format=full' | sed 's:.*/::g'
(Do note that you've exposed your user name and password to the world here...)
I want to create curl with #!/bin/sh script and the part that giving me a headache is:
STR="-XGET -v -H 'Authorization: Bearer "$TOKEN"' https://my_endpoint/sth?"
echo $STR
CON="$(curl $STR)"
The echo there is:
-XGET -v -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJleHAiOjE0NTM5NzIxODcsInVzZXJuYW1lIjoid2luZ3UtY2xpZW50LWFkbWluQHNwZWljaGVyMjEwLmNvbSIsImlhdCI6IjE0NTM4ODU3ODcifQ.ADLcrV4yph6owwgMLak2RsnC95WK17ULflCisvNWBkeA93G4WUQ-BMrjnhQeuIgSfxSYnAmgmI36ggc2PytWhkqk8lIYrMJTH80tggBYCnnuA2lM26IZ2ViUMK1cj-BH3-dh4HmqSm_hozAFnVqGQi9P5J4CBz8eCf_mKc3iq-7EnXRikTkgakF69-jPfFA_9yO26JzZeDpymowa-LRPafWPtYinzmkaUQ2SHjUdWtGmELAyzkGUOOXrZ8TgvV9Yeb-OnEoY54GRSlb4ogVzAwWCJ2Y6vxmvNpAN5wiUZMylqTGhnqFr9MOp4JId1RavjwT7STRp9bCHBxD55CtYoEQ-oSpDv6WkgB07CtCRi0Spx9ErVsaB0Xf1mH9XKAVjOQ_dNNpKTxlqIXMbbosxEhjYE9K6Z30c3uWhCgccNdEEHxPhi7d2bRO3M_3fJPKsYWWk5DXhxmkFpJ4fLf05JO31FFIoj8q7H3c5NEvXVk_keS-jPY5iP5xRY1dv9P8bWPEwFk1-qQrXZ1mMNiLDLxdB9cXE9Tm6Eo4Rxo71H2o4Z1DHmnVHHctsATzywsJIe3o8Ym5o0OsmS3WH3EJ-IS572lFv-ZQSkt3fq927JlvWotd9HHMT2MOPf8Zg5cdNd-hclZUfj7qOi-a0Afbn2cT3FccBXJ8l4' https://my_endpoint/sth?
And when i copy this from terminal and paste it into curl it works, but in the verbose log I find:
-XGET -v -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJleHAiOjE0NTM5NzIxODcsInVzZXJuYW1lIjoid2luZ3UtY2xpZW50LWFkbWluQHNwZWljaGVyMjEwLmNvbSIsImlhdCI6IjE0NTM4ODU3ODcifQ.ADLcrV4yph6owwgMLak2RsnC95WK17ULflCisvNWBkeA93G4WUQ-BMrjnhQeuIgSfxSYnAmgmI36ggc2PytWhkqk8lIYrMJTH80tggBYCnnuA2lM26IZ2ViUMK1cj-BH3-dh4HmqSm_hozAFnVqGQi9P5J4CBz8eCf_mKc3iq-7EnXRikTkgakF69-jPfFA_9yO26JzZeDpymowa-LRPafWPtYinzmkaUQ2SHjUdWtGmELAyzkGUOOXrZ8TgvV9Yeb-OnEoY54GRSlb4ogVzAwWCJ2Y6vxmvNpAN5wiUZMylqTGhnqFr9MOp4JId1RavjwT7STRp9bCHBxD55CtYoEQ-oSpDv6WkgB07CtCRi0Spx9ErVsaB0Xf1mH9XKAVjOQ_dNNpKTxlqIXMbbosxEhjYE9K6Z30c3uWhCgccNdEEHxPhi7d2bRO3M_3fJPKsYWWk5DXhxmkFpJ4fLf05JO31FFIoj8q7H3c5NEvXVk_keS-jPY5iP5xRY1yirgabLv9P8bWPEwFk1-qQrXZ1mMNiLDLxdB9cXE9Tm6Eo4Rxo71H2o4Z1DHmnVHHctsATzywsJIe3o8Ym5o0OsmS3WH3EJ-IS572lFv-ZQSkt3fq927JlvWot5MN9HHMT2MOPf8Zg5c6udNd-hclZUfj7qOi-a0Afbn2cT3FccBXJ8l4' https://my_endpoint/sth?
* Rebuilt URL to: Bearer/
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Could not resolve host: Bearer
* Closing connection 0
curl: (6) Could not resolve host: Bearer
* Rebuilt URL to: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJleHAiOjE0NTM5NzIxODcsInVzZXJuYW1lIjoid2luZ3UtY2xpZW50LWFkbWluQHNwZWljaGVyMjEwLmNvbSIsImlhdCI6IjE0NTM4ODU3ODcifQ.ADLcrV4yph6owwgMLak2RsnC95WK17ULflCisvNWBkeA93G4WUQ-BMrjnhQeuIgSfxSYnAmgmI36ggc2PytWhkqk8lIYrMJTH80tggBYCnnuA2lM26IZ2ViUMK1cj-BH3-dh4HmqSm_hozAFnVqGQi9P5J4CBz8eCf_mKc3iq-7EnXRikTkgakF69-jPfFA_9yO26JzZeDpymowa-LRPafWPtYinzmkaUQ2SHjUdWtGmELAyzkGUOOXrZ8TgvV9Yeb-OnEoY54GRSlb4ogVzAwWCJ2Y6vxmvNpAN5wiUZMylqTGhnqFr9MOp4JId1RavjwT7STRp9bCHBxD55CtYoEQ-oSpDv6WkgB07CtCRi0Spx9ErVsaB0Xf1mH9XKAVjOQ_dNNpKTxlqIXMbbosxEhjYE9K6Z30c3uWhCgccNdEEHxPhi7d2bRO3M_3fJPKsYWWk5DXhxmkFpJ4fLf05JO31FFIoj8q7H3c5NEvXVk_keS-jPY5iP5xRY1yirgabLv9P8bWPEwFk1-qQrXZ1mMNiLDLxdB9cXE9Tm6Eo4Rxo71H2o4Z1DHmnVHHctsATzywsJIe3o8Ym5o0OsmS3WH3EJ-IS572lFv-ZQSkt3fq927JlvWot5MN9HHMT2MOPf8Zg5c6udNd-hclZUfj7qOi-a0Afbn2cT3FccBXJ8l4'/
* Could not resolve host: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJleHAiOjE0NTM5NzIxODcsInVzZXJuYW1lIjoid2luZ3UtY2xpZW50LWFkbWluQHNwZWljaGVyMjEwLmNvbSIsImlhdCI6IjE0NTM4ODU3ODcifQ.ADLcrV4yph6owwgMLak2RsnC95WK17ULflCisvNWBkeA93G4WUQ-BMrjnhQeuIgSfxSYnAmgmI36ggc2PytWhkqk8lIYrMJTH80tggBYCnnuA2lM26IZ2ViUMK1cj-BH3-dh4HmqSm_hozAFnVqGQi9P5J4CBz8eCf_mKc3iq-7EnXRikTkgakF69-jPfFA_9yO26JzZeDpymowa-LRPafWPtYinzmkaUQ2SHjUdWtGmELAyzkGUOOXrZ8TgvV9Yeb-OnEoY54GRSlb4ogVzAwWCJ2Y6vxmvNpAN5wiUZMylqTGhnqFr9MOp4JId1RavjwT7STRp9bCHBxD55CtYoEQ-oSpDv6WkgB07CtCRi0Spx9ErVsaB0Xf1mH9XKAVjOQ_dNNpKTxlqIXMbbosxEhjYE9K6Z30c3uWhCgccNdEEHxPhi7d2bRO3M_3fJPKsYWWk5DXhxmkFpJ4fLf05JO31FFIoj8q7H3c5NEvXVk_keS-jPY5iP5xRY1yirgabLv9P8bWPEwFk1-qQrXZ1mMNiLDLxdB9cXE9Tm6Eo4Rxo71H2o4Z1DHmnVHHctsATzywsJIe3o8Ym5o0OsmS3WH3EJ-IS572lFv-ZQSkt3fq927JlvWot5MN9HHMT2MOPf8Zg5c6udNd-hclZUfj7qOi-a0Afbn2cT3FccBXJ8l4'
* Closing connection 1
curl: (6) Could not resolve host: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJleHAiOjE0NTM5NzIxODcsInVzZXJuYW1lIjoid2luZ3UtY2xpZW50LWFkbWluQHNwZWljaGVyMjEwLmNvbSIsImlhdCI6IjE0NTM4ODU3ODcifQ.ADLcrV4yph6owwgMLak2RsnC95WK17ULflCisvNWBkeA93G4WUQ-BMrjnhQeuIgSfxSYnAmgmI36ggc
* Trying 54.228.198.226...
* Connected to my_endpoint (54.228.198.226) port 443 (#2)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.herokuapp.com
* Server certificate: DigiCert SHA2 High Assurance Server CA
* Server certificate: DigiCert High Assurance EV Root CA
> GET /api/sth? HTTP/1.1
> Host: my_endpoint/sth?
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Connection: keep-alive
< Server: nginx/1.8.0
< Content-Type: application/json
< Transfer-Encoding: chunked
< X-Powered-By: PHP/5.6.17
< Cache-Control: no-cache
< Allow: GET
< Date: Wed, 27 Jan 2016 09:09:49 GMT
< Via: 1.1 vegur
<
{ [59 bytes data]
100 48 0 48 0 0 41 0 --:--:-- 0:00:01 --:--:-- 0
* Connection #2 to host my_endpoint left intact
What's wrong with that header?
Use an array to store command arguments.
curl_options=(-XGET -v -H "Authorization: Bearer $TOKEN" "https://my_endpoint/sth?")
content=$(curl "${curl_options[#]}")
You can use
eval curl $STR "https://my_endpoint" > 'output_file'
Using the code here http://fusion-tables-api-samples.googlecode.com/svn/trunk/ftapi/ [1] I can produce a successful response by running [2] cat PATHTOMYDATA.csv | ./ftupload.sh MYTABLEID . But I see no change in the Fusion Table specified by MYTABLEID
Some things I've tried:
-upload to new, blank table with correct number of columns ... same result
-upload to other table with incorrect number of columns ... receive error about columns
-various modifications of the curl command in ftupload.sh [3]
--remove -s -S (so can get full output) ... same result
--giving file as parameter rather than streaming standard input [4] ... same result
--sending without --data-binary flag.. produces HTTP/1.1 405 Method Not Allowed
--sending with -v flag, produces the following log of HTTP request [5]
[1] Which is functionally identical to http://fusion-tables-api-samples.googlecode.com/svn/trunk/ftapi, since that code doesn't change from rev56 to rev57
[2] On bash/Ubuntu
[3] originally:
curl -s -S --data-binary #- -H "Authorization: Bearer $access_token" \
-H "Content-Type: application/octet-stream" \
"https://www.googleapis.com/upload/fusiontables/v1/tables/$1/import"
[4]
curl -s -S --data-binary #PATHTOMYDATA.csv -H "Authorization: Bearer $access_token" \
-H "Content-Type: application/octet-stream" \
"https://www.googleapis.com/upload/fusiontables/v1/tables/$1/import"
[5]
* About to connect() to www.googleapis.com port 443 (#0)
* Trying 74.125.29.95... connected
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-RC4-SHA
* Server certificate:
* subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.googl eapis.com
* start date: 2013-06-19 12:43:04 GMT
* expire date: 2013-10-31 23:59:59 GMT
* subjectAltName: www.googleapis.com matched
* issuer: C=US; O=Google Inc; CN=Google Internet Authority
* SSL certificate verify ok.
> POST /upload/fusiontables/v1/tables/MYTABLEID/import HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zli b/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: www.googleapis.com
> Accept: */*
> Authorization: Bearer ya29.AHES6ZTZG_aqdYJYg-JgeAMOHOQIJOYFWAaGzzDWDlP2OKzpof8 MIkuPUA
> Content-Type: application/octet-stream
> Content-Length: 50
>
* upload completely sent off: 50out of 50 bytes
< HTTP/1.1 200 OK
< ETag: "TMh8SguO4XpkjXICbs8TpuVjR5I/BKKfZXT4y10ldV7sI6nrMgeYYNw"
< Content-Type: application/json
< Content-Length: 60
< Date: Fri, 28 Jun 2013 15:09:00 GMT
< Server: HTTP Upload Server Built on Jun 25 2013 11:32:14 (1372185134)
<
{
"kind": "fusiontables#import",
"numRowsReceived": "1"
}
* Connection #0 to host www.googleapis.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
There was a bug that swallowed the first row for uploads from the API. It was introduced around April 2013 and is fixed as of 8/1/2013.