4

data-encode-url in R

curl "https://www.zopim.com/api/v2/chats/search" \
-G --data-urlencode "q=timestamp:[2016-02-02T16:00:00 TO *] \
-v -u {email_address}:{password}

How to convert --data-urlencode this in R?

This is what I have so far: without the search part

  chats <<- getURL('https://www.zopim.com/api/v2/chats/', verbose = TRUE, userpwd = "username:pwd", httpauth = 1L)

where and how to add

--data-urlencode "q=timestamp:[2016-02-02T16:00:00 TO *]

in R?

1 Answer 1

5
library(httr)

GET(
  "https://www.zopim.com/api/v2/chats/search",
  query=list(
    q="timestamp:[2016-02-02T16:00:00 TO *] AND rating:good"
  ),
  authenticate("[email protected]", "yourpassword"),
  verbose()
) -> result

content(result, as="parsed")
## $results
## list()
## 
## $count
## [1] 0
## 
## $prev_url
## NULL
## 
## $next_url
## NULL

Remove the verbose() in production.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.