문제

With rest_client gem

I have to pass parametes and set http headers as well. parameters- {"module"=>{"id"=>376373}, "name"=>"test workflow", "playbooks"=>[{"name"=>"shell_book.yml"}]} headers- {Accept => application/json, content-type => application/json, mode => agentless}

please suggest how do i do this.

My code looks like this- RestClient.put(@@host+'/workflow/agentless', {:params => {"module"=>{"id"=>376373}, "name"=>"test workflow", "playbooks"=>[{"name"=>"shell_book.yml"}]} })

도움이 되었습니까?

해결책

The third parameter is the headers hash.

Try the code below with your values:

response = RestClient.put(url, request, :content_type => :json, :accept => :json)

다른 팁

I was missing params.to_json earlier... following worked for me.

RestClient.put(@@host+'/workflow/agentless', params.to_json, :content_type => :json, :accept => :json, :mode => :agentless)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top