Hi Team,
I'm doing the API integration with Genesis using R Studio (for R), where my purpose in to extract and load to our database on Genesis data for reporting work.
The problem I'm having is I used how the Python code is setup and used the similar method at the R.
But I'm keep on getting the 400 response code. Actually, I cannot figure out what is going wrong.
Appreciate if I can have bit of a help on this.
library(httr)
library(base64enc)
Set the API endpoint URL
url <- "https://login.mypurecloud.com/oauth/token"
encodedData <- base64enc::base64encode(charToRaw(paste0("myClientID", ":", "myClientSecreat")), newline = FALSE)
Set the request headers
headers <- c(
"Content-Type" = "application/x-www-form-urlencoded",
"Authorization" = paste("Basic ", encodedData)
)
Set the request body
body <- list(
grant_type = "client_credentials"
)
Send the POST request
response <- POST(url, add_headers(headers), body = body, encode = "form")