web-dev-qa-db-fra.com

Curl: (3) [Globbing] Brade imbriquée dans la colonne 189 lors de l'envoi de la demande de la demande de fichiers Google Feuilles API

J'essaie d'écrire à une feuille de calcul Google à l'aide de la feuille Google API V4. L'utilisation de l'API est répertoriée ICI

J'ai fait une demande curl qui ressemble à ce qui suit

curl -v\
-H 'Authorization: Bearer ya29.GlxSB9-EiDh1Mn2EqhCslHvkaGyOX-P4_yDR4MXOt-WdHYQdFfwUJNMfljAFzZfS-YrrATUU2MAKj3R4BcMyOSw55KjJOC0EekE_qusj8GXIxFF3uaGZxGMdlB0IlQ' \
-X PUT \
https://sheets.googleapis.com/v4/spreadsheets/1mHrPXQILuprO4NdqTgrVKlGazvvzgCFqIphGdsmptD8/values/Sheet1\!A1:D5\?valueInputOption\='{"range": "Sheet1!A1:D5","majorDimension": "ROWS","values": [["Item", "Cost", "Stocked", "Ship Date"]

Quand je cours ça, j'obtiens l'erreur suivante

curl: (3) [globbing] nested brace in column 189

Je ne comprends pas ce que je fais mal et j'apprécie toute aide ici

6
daydreamer

J'ai compris, mon utilisation de l'API était incorrecte. La bonne utilisation de l'API est

curl -v \
-H 'Authorization: Bearer ya29.GlxSB9-EiDh1Mn2EqhCslHvkaGyOX-P4_yDR4MXOt-WdHYQdFfwUJNMfljAFzZfS-YrrATUU2MAKj3R4BcMyOSw55KjJOC0EekE_qusj8GXIxFF3uaGZxGMdlB0IlQ' \
-H 'Content-Type: application/json' \
-X PUT \
-d '{"range": "Sheet1!A1:D5","majorDimension": "ROWS","values": [["Item", "Cost", "Stocked", "Ship Date"], ["Wheel", "$20.50", "4", "3/1/2016"], ["Door", "$15", "2", "3/15/2016"], ["Engine", "$100", "1", "30/20/2016"], ["Totals", "=SUM(B2:B4)", "=SUM(C2:C4)", "=MAX(D2:D4)"]]}' \
https://sheets.googleapis.com/v4/spreadsheets/1mHrPXQILuprO4NdqTgrVKlGazvvzgCFqIphGdsmptD8/values/Sheet1!A1:D5?valueInputOption=USER_ENTERED

Les points importants à noter sont
- valueInputOption=USER_ENTERED. Je devais dire à l'API d'analyser l'entrée alors USER_ENTERED était une valeur valide selon la - documentation
- L'utilisation de -H 'Content-Type: application/json' était nécessaire car la charge utile était un contenu valide json.
[.____] - Envoi de la charge utile à l'aide de -d option.

Une fois corrigé, j'ai pu frapper l'API et obtenir la réponse

*   Trying 2607:f8b0:400a:803::200a...
* TCP_NODELAY set
* Connected to sheets.googleapis.com (2607:f8b0:400a:803::200a) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* 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, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=California; L=Mountain View; O=Google LLC; CN=*.googleapis.com
*  start date: Jul  2 19:21:00 2019 GMT
*  expire date: Sep 24 18:57:00 2019 GMT
*  subjectAltName: Host "sheets.googleapis.com" matched cert's "*.googleapis.com"
*  issuer: C=US; O=Google Trust Services; CN=Google Internet Authority G3
*  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 0x7fc02e006600)
> PUT /v4/spreadsheets/1mHrPXQILuprO4NdqTgrVKlGazvvzgCFqIphGdsmptD8/values/Sheet1!A1:D5?valueInputOption=USER_ENTERED HTTP/2
> Host: sheets.googleapis.com
> User-Agent: curl/7.54.0
> Accept: */*
> Authorization: Bearer ya29.GlxSB9-EiDh1Mn2EqhCslHvkaGyOX-P4_yDR4MXOt-WdHYQdFfwUJNMfljAFzZfS-YrrATUU2MAKj3R4BcMyOSw55KjJOC0EekE_qusj8GXIxFF3uaGZxGMdlB0IlQ
> Content-Type: application/json
> Content-Length: 272
>
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
< HTTP/2 200
< content-type: application/json; charset=UTF-8
< vary: X-Origin
< vary: Referer
< vary: Origin,Accept-Encoding
< date: Sat, 27 Jul 2019 19:23:15 GMT
< server: ESF
< cache-control: private
< x-xss-protection: 0
< x-frame-options: SAMEORIGIN
< alt-svc: quic=":443"; ma=2592000; v="46,43,39"
< accept-ranges: none
<
{
  "spreadsheetId": "1mHrPXQILuprO4NdqTgrVKlGazvvzgCFqIphGdsmptD8",
  "updatedRange": "Sheet1!A1:D5",
  "updatedRows": 5,
  "updatedColumns": 4,
  "updatedCells": 20
}
* Connection #0 to Host sheets.googleapis.com left intact
3
daydreamer