gpt4 book ai didi

rest - curl: (3) [globbing] 向 Google Sheets API 发送 PUT 请求时第 189 列中的嵌套括号

转载 作者:行者123 更新时间:2023-12-03 14:38:48 26 4
gpt4 key购买 nike

我正在尝试使用 Google Sheet API v4 写入 Google 电子表格。
API使用情况列表here

我做了一个 curl如下所示的请求

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"]

当我运行这个时,我收到以下错误
curl: (3) [globbing] nested brace in column 189

我不明白我做错了什么,并感谢这里的任何帮助

最佳答案

我发现,我对 API 的使用是不正确的。 API的正确使用是

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

需要注意的要点是
- valueInputOption=USER_ENTERED .我不得不告诉 API 解析输入,所以 USER_ENTERED根据 documentation 是有效值
- 使用 -H 'Content-Type: application/json'需要,因为有效载荷是有效的 json内容。
- 使用 -d 发送有效载荷选项。

一旦更正,我就能够点击 API 并获得响应
*   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

关于rest - curl: (3) [globbing] 向 Google Sheets API 发送 PUT 请求时第 189 列中的嵌套括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57235170/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com