xml example
library(httr)
# Define the URL of the API endpoint
url <- "https://your.api.endpoint"
# Define the data to be sent in the POST request (replace with your actual data)
data <- list(
key1 = "value1",
key2 = "value2"
)
# Define the token (replace with your actual token)
token <- "your_access_token"
# Create the POST request with headers
response <- POST(
url,
body = data,
add_headers("Authorization" = paste("Bearer", token)),
encode = "json" # Specify the encoding, e.g., "json"
)
# Check the response
status_code <- status_code(response)
content <- content(response)
cat("Status Code:", status_code, "\n")
cat("Response Content:", content, "\n")
Comments
Post a Comment