首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从cURL华生的个性洞察力?

如何从cURL华生的个性洞察力?
EN

Stack Overflow用户
提问于 2017-10-07 15:08:38
回答 1查看 310关注 0票数 1

个性洞察教程说要使用以下cURL命令:

代码语言:javascript
复制
curl -X POST --user {username}:{password} \
--header "Content-Type: application/json" \
--data-binary "@{path_to_file}profile.json" \
"https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2016-10-20&consumption_preferences=true&raw_scores=true"

我已翻译为:

代码语言:javascript
复制
curl -X POST --user myun:mypw \
--header "Content-Type: application/json" \
--data-binary "@C:\mypath\profile.json" \
"https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2016-10-20&consumption_preferences=true&raw_scores=true"

我下载并安装了cURL,但是我一直在PowerShell中得到这些可怕的错误:

代码语言:javascript
复制
At line:2 char:3
+ --header "Content-Type: application/json" \
+   ~
Missing expression after unary operator '--'.
At line:2 char:3
+ --header "Content-Type: application/json" \
+   ~~~~~~
Unexpected token 'header' in expression or statement.
At line:3 char:3
+ --header "Accept: text/csv" \
+   ~
Missing expression after unary operator '--'.
At line:3 char:3
+ --header "Accept: text/csv" \
+   ~~~~~~
Unexpected token 'header' in expression or statement.
At line:4 char:3
+ --data-binary "C:\mypath\profile.json" \
+   ~
Missing expression after unary operator '--'.
At line:4 char:3
+ --data-binary "C:\mypath\profile.json" \
+   ~~~~~~~~~~~
Unexpected token 'data-binary' in expression or statement.
At line:5 char:3
+ --output "C:\profile.csv" \
+   ~
Missing expression after unary operator '--'.
At line:5 char:3
+ --output "C:\profile.csv" \
+   ~~~~~~
Unexpected token 'output' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpressionAfterOperator

以下是我尝试过的:

  • myun:mypw放在双引号中
  • data-binary后移除符号
  • 搜索“表达式或语句中的”意外标记“头”。但这似乎是一个逐案的基础(这意味着这可能也是一个)。
  • 我理解windows的cURL不喜欢单引号,但是我在这里没有看到任何单引号,我不确定是否还有其他的特性可能会影响到这一点。
EN

回答 1

Stack Overflow用户

发布于 2017-10-07 20:19:01

PowerShell中的换行符不是由\转义,而是由后勾`转义。因此,如果您想在PowerShell中执行此命令,可以避免转义换行符,或者使用倒计时:

代码语言:javascript
复制
curl -X POST --user myun:mypw `
--header "Content-Type: application/json" `
--data-binary "@C:\mypath\profile.json" `
"https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2016-10-20&consumption_preferences=true&raw_scores=true"

不过,避免倒计时会更好,因为它们很难读懂。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46621706

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档