鉴于以下curl将发布到我的服务器,我可以在自动化脚本中使用的等效Ruby代码是什么?我查看过这篇文章What is the Ruby equivalent to this curl request?但是很高兴知道curl的语法相当于cur的-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
这个ruby代码给出了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