0
我有一个正常运作的shell脚本,它看起来是这样的(工作在终端):时,如何在使用curl时发送http标头?
curl -X POST --compressed -H "Content-Type:application/json" \
-H 'x-api-user: hdfjdfpjefpoj' \
-H 'x-api-key: fpjefpojwpfjmwefpj' \
https://example.com/api/v1/user/...
然而,当我尝试使用do shell script
使用这一个AppleScript,我得到的错误:
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
sh: line 1: -H: command not found
sh: line 2: -H: command not found
sh: line 3: https://example.com/api/v1/user/...: No such file or directory
这里的AppleScript的:
do shell script "curl -X POST --compressed -H 'Content-Type:application/json'
-H 'x-api-user: hdfjdfpjefpoj'
-H 'x-api-key: fpjefpojwpfjmwefpj'
https://example.com/api/v1/user/..."
我已经找到了一些线索表明do shell script
不表现就像终端一样,出于安全原因。但是我还没有找到如何解决这个问题的线索。
没有标头信息的相同Applescript成功地传递了URL,但我需要在标头中发送我的凭证。
高五!感谢帮助。 – rda3000