can you add the login and password "library(httr)
library(openssl)
library(digest)
URL
url <- "https://586038.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=3612&deploy=1"
JSON body
body <- list(
query = "Select LastName from CONTACT where FirstName='Livio'"
)
Authentication credentials
consumer_key <- "200b3bacd548c08046abbdcb50b5374445f8081176e0fe1ca28a2d80918686d1"
consumer_secret <- "91a127b1123f622bd951c9a52f6c3609449fbb05101fd2f5df1a13ca105c2932"
token_key <- "58a0591cde917e0782c4f6d38a20dab26a1c544b65440d98bb15989c637c5a73"
token_secret <- "4b58a072c9462a5288c2a0e866b31ddc0c3714f94b5e2e323ce5297ac3139a63"
Generating OAuth signature
method <- "POST"
timestamp <- as.character(as.integer(Sys.time()))
nonce <- charToRaw(paste0(sample(letters, 32, replace = TRUE), collapse = ""))
signature_base <- paste0(method, "&", URLencode(url), "&",
URLencode(paste("deploy=1", paste0("oauth_consumer_key=", consumer_key, "&",
"oauth_nonce=", rawToChar(nonce), "&",
"oauth_signature_method=HMAC-SHA256&",
"oauth_timestamp=", timestamp, "&",
"oauth_token=", token_key, "&",
"oauth_version=1.0", sep = ""))),
"&", URLencode(paste("query=", body$query, sep = "")))
signature_key <- paste(consumer_secret, "&", token_secret, sep = "")
signature <- hmac(signature_base, key = signature_key, algo = "sha256")
signature <- charToRaw(signature)
signature <- paste(rawToChar(signature), collapse = "")
oauth_header <- paste("OAuth ", paste(paste0('oauth_consumer_key="', consumer_key, '"'),
paste0('oauth_nonce="', rawToChar(nonce), '"'),
paste0('oauth_signature="', signature, '"'),
paste0('oauth_signature_method="HMAC-SHA256"'),
paste0('oauth_timestamp="', timestamp, '"'),
paste0('oauth_token="', token_key, '"'),
paste0('oauth_version="1.0"'), sep = ", "), sep = "")
# Sending POST request with JSON body and OAuth authentication header
response <- POST(url, body = body, encode = "json", add_headers(Authorization = oauth_header))
# Print response
print(content(response))