Rest API GET request on ClickSend fails to authenticate

Hi. Trying to send a GET request using httr to ClickSend. The url "" authenticates OK in another platform (FileMaker script). I need to query to get a list of lists.
This responds with a code 200
CSUrl <- ""

# delete TK from ClickSend
response <- GET(CSUrl, authenticate("","password"))

This responds with a code 401
CSUrl <- ""

# delete TK from ClickSend
response <- GET(CSUrl, authenticate("","password"))
1 Like

Hello Cameron,

One issue I can see is when you send a GET request to
CSUrl <- ""

This endpoint does not care about authentication and will always return a 200 response.

I would advise checking your credentials, as when I do a direct copy of your code adding my own credentials, I receive the expected 200 OK response.

Response []
  Date: 2020-05-18 00:55
  Status: 200
  Content-Type: application/json
  Size: 1.23 kB
1 Like

@Jaxom. Thank you. The issue was just a simple syntax issue. I delimited the username and password with a colon in my actual code, not a comma, a throwback to another platform. Thanks for prompting me to look at it in more detail.

Now I have got that far, I have successfully deleted a contact list, but can't get passed this, using a POST to create a list.

ListName <- paste0("\"list_name:", ListName, "\"")
CSUrl <- paste("")
POST(CSUrl, authenticate("username","password"), body = ListName, content_type('json'))

Clearly not a REST API/cURL expert, any help would be appreciated.

ClickSend developer notes show this as the POST request for cURL. Any help to transpose to R would be great. Thanks in advance.

curl --include \
     --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \
     --request POST \
     --header "Content-Type: application/json" \

     --data-binary "    {
    }" \
1 Like

Here is an example of how I got it working:

httr::POST("", encode = "json", httr::authenticate("username","password"), body = list(list_name = "test"))

If you provide the payload in a list format with the encode set to json, httr will send it in the json format.

Thank you so much @Jaxom. Detail, detail, details.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.