2

I am trying to replicate the curl method mentioned in splunk rest api doc into R to perform search using R. Sorry, I won't be able provides details on the parameters to replicate. Hence attaching the link for reference.

curl -u admin:changeme -k https://localhost:8089/services/search/jobs -d search="search *"

This returns me a sid from curl. However when I try to replicate the same in R using httr it returns list of all search details. I have tried using both POST & GET in httr just in case. Below is sample code. Ideally below one should return me a sid. however it returns list of existing search details. Not sure what I am missing. I am new to Rcurl,httr. I tried curlperform as well, there also same. Seems, something is missing out. What exactly -d does in curl, is this the thing I am missing to replicate ?

response <- GET(splunk_server,path=search_job_export_endpoint,
                    config(ssl_verifyhost=FALSE, ssl_verifypeer=0),
                   authenticate(username, password),
                   query=list(search=urlencode(search_terms)),                             
                   verbose())

  result <- read.table(text=content(response, as="text"), sep=",", header=TRUE,
                       stringsAsFactors=FALSE)
Deb
  • 193
  • 1
  • 3
  • 20
  • I found one similar issue but here the platform used is java. http://filecentral.us/is-d-of-curl-the-same-as-formdata-in-xmlhttprequest-post/ – Deb Sep 03 '15 at 06:32
  • See if this - http://stackoverflow.com/questions/32276780/how-to-convert-splunk-curl-query-into-rcurl - helps. If so, I can mark this as a dup. – hrbrmstr Sep 03 '15 at 10:10
  • Its similar, and giving the same output – Deb Sep 03 '15 at 10:12

0 Answers0