Question

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"}]} })

Was it helpful?

Solution

The third parameter is the headers hash.

Try the code below with your values:

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

OTHER TIPS

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top