'我有一个巨大的XML文件,需要在端点上将其放入。我的curl命令目前看起来像:
curl -X PUT --user user:pass https://<end-point>/foo/bar/id \
-H 'Content-Type: application/json' \
-d '{
"medata": "${METADATA}"
}'
我的METADATA
来自:
METADATA=$(cat cost_meta.xml)
cost_meta.xml
大致如下:
<?xml version="1.0" encoding="UTF-8"?>
<md:EntityDescriptor ID="_ydkjknxyky6vepon"
.
.
index="0"/></md:SPSSODescriptor></md:EntityDescriptor>
XML本身很好。我刚刚将其修剪并张贴在这里。
运行curl
命令时,出现错误消息
Failed to upsert service provider due to invalid JSON input.zsh: command not found: -H
zsh: command not found: -d
所以我尝试了另一种方法:
curl -H "Content-Type: text/xml" -d @cost_meta.xml -X POST --user user:pass https://<end-point>/foo/bar/id
但这给我一个
的错误<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>417 Expectation Failed</title>
</head><body>
<h1>Expectation Failed</h1>
<p>The expectation given in the Expect request-header
field could not be met by this server.
The client sent<pre>
Expect: 100-continue
</pre>
</p><p>Only the 100-continue expectation is supported.</p>
</body></html>
所以我不确定下一步该怎么做。有什么想法我做错了吗?
答案 0 :(得分:0)
您的脚本似乎还不错,除了其他换行符并对应于错误消息,添加一个-H 'Expect:'
,所以写
curl -X PUT --user user:pass https://<end-point>/foo/bar/id \
-H 'Content-Type: application/json' -H 'Expect:' \
-d '{"medata": "'"$(cat cost_meta.xml)"'"}'