Sample code for 30+ languages & platforms
Lua Requires Chilkat v11.0.0+

NetSuite OAuth1

See more OAuth1 Examples

Demonstrates adding OAUth1 authentication to a NetSuite REST API request.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- It requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.

local http = chilkat.Http.new()

http.oauth1 = true
http.oauth_consumer_key = "CONSUMER_KEY"
http.oauth_consumer_secret = "CONSUMER_SECRET"
http.oauth_token = "ACCESS_TOKEN"
http.oauth_token_secret = "TOKEN_SECRET"
http.oauth_realm = "ACCOUNT_ID"
http.oauth_sig_method = "HMAC-SHA256"

-- Not sure if this is needed for NetSuite requests.
http:set_request_header("Cookie", "NS_ROUTING_VERSION=LAGGING")

-- Replace ACCOUNT_ID with your actual account id, which is likely a 7-digit decimal number.
local resp = chilkat.HttpResponse.new()
local success = http:http_no_body("GET", "https://ACCOUNT_ID.suitetalk.api.netsuite.com/services/rest/record/v1/salesOrder", resp)
if not success then
    print(http.last_error_text)
    return
end

print("Response Status Code: " .. resp.status_code)
print("Response Body:")
print(resp.body_str)