问题描述
我无法使用PowerShell(Windows运行程序)从YML Gitlab管道提交Dropbox API请求。该API要求传递JSON作为标头参数,并将该JSON编码到YML Gitlab Pipeline中不起作用:
`--header "Dropbox-API-Arg:{\"path\":\"/$BUILD_FILENAME\"}"
下面是完整脚本步骤,因为它已在YML中定义:
- C:\Windows\System32\curl.exe -X POST https://content.dropboxapi.com/2/files/upload --header "Authorization:Bearer $DROPBOX_TOKEN" --header "Content-Type:application/octet-stream" --header "Dropbox-API-Arg:{\"path\":\"/$BUILD_FILENAME\"}" --data-binary @$BUILD_FULLFILENAME
响应错误如下:
Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": could not decode input as JSONcurl: (3) Port number ended with '\'
我可以在运行Windows的同一台PC上的Windows PowerShell中执行上述命令:
curl -X POST https://content.dropboxapi.com/2/files/upload --header "Authorization: Bearer XXX" --header "Dropbox-API-Arg: {\"path\": \"/README.md\"}" --header "Content-Type: application/octet-stream" --data-binary @README.md
如何正确编码JSON,以便可以按预期执行并传递给CURL?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)