我的招摇是我的要求
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \
"version": "v15" \
}' 'https://XXX.XX.XXX.XXX/tools/v1/termsAndConditions'
我的红宝石代码是
payload={
:multipart => true,
}
headers1 = {
:content_type => 'multipart/form-data',
:accept => 'application/json',
# -d ':version=> 'v16'
}
begin
response= RestClient::Request.execute(
:url => "https://XXX.XX.XXX.XXX/tools/v1/termsAndConditions",
:method => :post,
:headers => headers1,
:verify_ssl => false,
:proxy => nil,
:payload=>payload
)
rescue RestClient::BadRequest => err
@responsebody=err.response.body
@responseCode="400"
else
@responseCode=response.code
@responsebody=response.body
end
如何在标题或有效负载中传递以下内容来复制swagger?
'-d'{\“version”:“v15”\}'
-d
是你的帖子请求中的数据参数,它与headers
无关。
payload={
version: 'v15',
}.to_json
而你的其余代码应该是一样的。我不知道为什么你需要在你的有效载荷内部使用:multipart => true
。