鉴于以下 curl 将发布到我的服务器,我可以在自动化脚本中使用的等效 Ruby 代码是什么?我查看了这篇文章什么是 Ruby 等价于这个 curl 请求?但很高兴知道 curl 的 -u admin:admin 等价的遏制语法......这个 curl 成功发布
curl -u admin:admin -F":operation=import" -F":contentType=json" -F":name=sample" -F":content={ 'jcr:primaryType': 'nt:unstructured', 'propOne' : 'propOneValue', 'childOne' : { 'childPropOne' : true } }" http://localhost:4502/content/michigan-lsa/stats/en/people/person/jcr%3Acontent
这个红宝石代码给出了 500 错误。任何指针将不胜感激
def postProfileContent
@profilePath = "http://localhost:4502/content/michigan-lsa/#{@dept}/en/people/#{@category}/#{@uniqueName}/jcr%3Acontent"
c = Curl::Easy.new
c.url = "#{@profilePath}"
c.verbose = true
c.http_auth_types = :basic
c.username = "admin"
c.password = "admin"
c.enable_cookies = true
c.follow_location = true
puts c.cookies
ask "FINISHED: HTTP #{c.response_code}"
#set post
c.http_post("#{@profilePath}",@jsonContent.to_json)
ask "FINISHED: HTTP #{c.response_code}"
end