def post_json(e, json, p = {})
url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
msg "#{url} #{json}", Logger::DEBUG
params = { :content_type => "application/json" }.merge! p
params[:cookies] = $cookie if !$cookie.empty?
resp = RestClient.post(url, json, params )
begin
msg resp, Logger::DEBUG
$cookie = resp.cookies unless resp.cookies.empty?
msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
jresp = JSON resp
if jresp
return jresp
end
rescue JSON::ParserError => e
end
return resp
end