【发布时间】:2018-10-24 14:40:06
【问题描述】:
'我有一个巨大的 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>
所以我不确定下一步该做什么。任何想法我做错了什么?
【问题讨论】:
-
是
PUT还是POST?你两个都用。 -
我第一次尝试应该是
PUT。但我也试过POST -
在您的元数据作业中添加引号 -
METADATA="$(cat cost_meta.xml)" -
您的代码中 curl 的参数上方是否有空行?
-
是的,空行是个问题。但现在我得到
Invalid JSON provided as input. Could not parse the service provider's trust settings