我正在使用虚拟化软件,该软件允许我通过POST请求更新正在运行的虚拟服务。通过Web浏览器中提供的UI完成发布请求后,该发布请求才起作用。它还在网页上生成curl命令。
curl -X POST "http://localhost:1505/lisa-virtualize-invoke/api/v3/vses/VSE/services/API_Test_22" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "deploy=true" -F "[email protected];type=application/x-zip-compressed"
但是,当我尝试在bash中使用提供的curl命令时,它不起作用。我需要能够对jenkinsfile使用curl。
我尝试了'inputFile1'的不同变体,例如:
-F "[email protected];type=application/x-zip-compressed"
-F "[email protected]"
在GitBash中,我得到了一个乱码的非ASCII字符作为输出。
在Ubuntu终端中,我收到另一个错误:
curl -X POST -H "authorization: Basic xxx" "http://10.0.2.2:1505/lisa-virtualize-invoke/api/v3/vses/VSE/services/API_Test_22" -H "accept: application/zip" -H "Content-Type: multipart/form-data" -F "deploy=true" -F "inputFile1=@\"updateCustomer.zip\""
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
我在詹金斯的输出是:
+ curl -X POST -H authorization: Basic xxx http://10.0.2.2:1505/lisa-virtualize-invoke/api/v3/vses/VSE/services/API_Test_22 -H accept: application/zip -H Content-Type: multipart/form-data -F deploy=true -F [email protected]
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 63261 0 0 100 63261 0 52325 0:00:01 0:00:01 --:--:-- 52325
100 63261 0 0 100 63261 0 28599 0:00:02 0:00:02 --:--:-- 28599
100 63261 0 0 100 63261 0 19682 0:00:03 0:00:03 --:--:-- 19689
100 63261 0 0 100 63261 0 15004 0:00:04 0:00:04 --:--:-- 15008
100 63261 0 0 100 63261 0 12121 0:00:05 0:00:05 --:--:-- 12121
100 63261 0 0 100 63261 0 10165 0:00:06 0:00:06 --:--:-- 0
100 63971 0 710 100 63261 103 9220 0:00:06 0:00:06 --:--:-- 152PK�S�N .maraudit����n�q�w � �4���g���ؤ��(�T�l�o @�1r�~����} &-������U�ƨ���������>���������o�_��g��W�����?���_~�����?��7��~˟����7�����7����?���_�~�B��?��/b����2��h���C�!���������������/ ...
我接受第二条评论作为我的问题的答案。
“对于乱码二进制数据,您发送标头-H” accept:application / zip“,它告诉服务器我希望我以gzip格式(二进制格式)进行响应。回应,那就是您得到的。” – hanshenrik 7月16日12:01