个性洞察教程说要使用以下cURL命令:
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"我已翻译为:
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中得到这些可怕的错误:
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后移除符号发布于 2017-10-07 20:19:01
PowerShell中的换行符不是由\转义,而是由后勾`转义。因此,如果您想在PowerShell中执行此命令,可以避免转义换行符,或者使用倒计时:
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"不过,避免倒计时会更好,因为它们很难读懂。
https://stackoverflow.com/questions/46621706
复制相似问题