0

My query is this

q = '{ "script":"ctx._source.id = val", "params":{ "val":11316623} }'
   _id="11316623"
   response = JSON.parse(RestClient.post("http://mydomain:9200/monitoring/mention_reports/#{_id}/_delete", q))

it gives us

/usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!': 400 Bad Request (RestClient::BadRequest)
    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:230:in `process_result'
    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `transmit'
    from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'

    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'

from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient.rb:72:in `post'

Please help me

Ravendra Kumar
  • 1,072
  • 10
  • 29

1 Answers1

1

Please do in this way

 mydomain = "ec2-222-333-444-244.us-west-1.compute.amazonaws.com"
 q= '{ "script":"ctx._source.id = val", "params":{ "val":11316623} }'
 _id = "11316623"
 response = RestClient.post "http://#{mydomain}/monitoring/mention_reports/#{_id}/_delete", :q => q, :content_type => :json, :accept => :json
 json_res = JSON.parse(response) 

it should be

RestClient.post 'http://example.com/resource', :param1 => 'one', :nested => { :param2 => 'two' } in this format

Rajarshi Das
  • 11,778
  • 6
  • 46
  • 74
  • it gives us from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:116:in `parse_url_with_auth' from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:63:in `execute' from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute' from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient.rb:72:in `post' – Ravendra Kumar Aug 30 '13 at 08:33
  • i am hitting this script q = '{ "script":"ctx._source.id = val", "params":{ "val":11316623} }' _id="11316623" response = JSON.parse(RestClient.post(URI("http://mydomain:9200/monitoring/mention_reports/#{_id}/_delete"), q)) and it gives us above error – Ravendra Kumar Aug 30 '13 at 08:36
  • please post your errors it is hard to understand what parsing it wants – Rajarshi Das Aug 30 '13 at 08:39
  • /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!': 400 Bad Request (RestClient::BadRequest) – Ravendra Kumar Aug 30 '13 at 08:41
  • if it iis running in your locally then it should be `localhost` or any `IP` – Rajarshi Das Aug 30 '13 at 08:43
  • ec2 sever domain like this ec2-222-333-444-244.us-west-1.compute.amazonaws.com – Ravendra Kumar Aug 30 '13 at 08:43
  • it should be `RestClient.post 'http://example.com/resource', :param1 => 'one', :nested => { :param2 => 'two' }` in this format – Rajarshi Das Aug 30 '13 at 08:46
  • `RestClient.post "http://#{mydomain}/monitoring/mention_reports/#{_id}/_delete", :params1 => q` and `mydomain = ec2-222-333-444-244.us-west-1.compute.amazonaws.com ` – Rajarshi Das Aug 30 '13 at 08:47
  • i can,t understand this please specify in your answer.thanks in advance – Ravendra Kumar Aug 30 '13 at 08:48