将cURL转换为Applescript

问题描述 投票:0回答:1

我正在尝试使用“ do shell script”将cURL命令转换为AppleScript。我使用了以前的帖子中的各种提示,但仍然遇到错误。谁能指出我的语法错误。

以下脚本在终端中运行时效果很好。

    curl -X POST https://content.dropboxapi.com/2/files/upload \
  --header 'Authorization: Bearer MYTOKEN' \
  --header 'Content-Type: application/octet-stream' \
  --header 'Dropbox-API-Arg: {"path":"/RoomVT/Clown2.jpeg"}' 
  --data-binary @"/Splash.jpeg"

然后适应。

--Add do shell script Command--
--Place The cURL Inside Double Quotes--
--Replace Double Quotes With Single Quotes--
--Remove Backslashes At End Of Lines--
--You May Also Need To Place All In A Single Line--

do shell script "curl -X POST https://content.dropboxapi.com/2/files/upload --header 'Authorization: Bearer MYTOKEN' --header 'Content-Type: application/octet-stream' --header 'Dropbox-API-Arg: {'path':'/RoomVT/Clown2.jpeg'}' --data-binary @'/Splash.jpeg'"

我仍然收到错误。

“调用API函数\“文件/上传\”时出错:HTTP标头\“ Dropbox-API-Arg \”:无法将输入解码为JSON“

json applescript dropbox-api
1个回答
0
投票

感谢您的评论。我接受@RobC的建议,它第一次起作用。

do shell script "curl -X POST https://content.dropboxapi.com/2/files/upload --header 'Authorization: Bearer b4Itg9wetFIAAAAAAAAD7PPkCmoIE2oXvkx_-nq1L2D5G7Bfla-5LHKHtJqoeBMc' --header 'Content-Type: application/octet-stream' --header 'Dropbox-API-Arg: {\"path\":\"/EngineRoomVT/Clown2.jpeg\"}' --data-binary @\"/Splash.jpeg\""
© www.soinside.com 2019 - 2024. All rights reserved.