This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*@NApiVersion 2.x | |
*@NScriptType ScheduledScript | |
*/ | |
define(['N/task','N/log'], | |
function(task) | |
{ | |
function execute(context) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public TokenPassport CreateTokenPassport() | |
{ | |
String nonce = ComputeNonce(); | |
long timestamp = ComputeTimestamp(); | |
string account = ConfigurationManager.AppSettings["login.acct"]; | |
string consumerKey = ConfigurationManager.AppSettings["login.tbaConsumerKey"]; | |
string consumerSecret = ConfigurationManager.AppSettings["login.tbaConsumerSecret"]; | |
string tokenId = ConfigurationManager.AppSettings["login.tbaTokenId"]; | |
string tokenSecret = ConfigurationManager.AppSettings["login.tbaTokenSecret"]; | |
TokenPassportSignature signature = ComputeSignature(account, consumerKey, consumerSecret, tokenId, tokenSecret, nonce, timestamp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NetSuiteService nss = new NetSuiteService(); | |
nss.Url = "https://your-accountID.suitetalk.api.netsuite.com/services/NetSuitePort_2023_1"; | |
nss.tokenPassport = CreateTokenPassport(); // | |
TransactionSearchAdvanced tranSearch = new TransactionSearchAdvanced(); //TransactionSearchAdvanced type depends on your search object references. | |
tranSearch.savedSearchId = "searchID here"; | |
try | |
{ | |
var searchResult = nss.search(tranSearch); | |
if (searchResult.status.isSuccess) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string ComputeNonce() | |
{ | |
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); | |
byte[] data = new byte[20]; | |
rng.GetBytes(data); | |
int value = Math.Abs(BitConverter.ToInt32(data, 0)); | |
return value.ToString(); | |
} | |
private long ComputeTimestamp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<soap:Envelope | |
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" | |
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" | |
xmlns:messages="urn:messages_2023_1.platform.webservices.netsuite.com" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<soap:Header> | |
<urn:tokenPassport xmlns:urn="urn:messages_2023_1.platform.webservices.netsuite.com"> | |
<ns8:account xmlns:ns8="urn:core_2023_1.platform.webservices.netsuite.com">********</ns8:account> | |
<ns8:consumerKey xmlns:ns8="urn:core_2023_1.platform.webservices.netsuite.com">************</ns8:consumerKey> | |
<ns8:token xmlns:ns8="urn:core_2023_1.platform.webservices.netsuite.com">*************</ns8:token> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:messages_2023_1.platform.webservices.netsuite.com" xmlns:urn1="urn:core_2023_1.platform.webservices.netsuite.com"> | |
<soapenv:Header> | |
<urn:tokenPassport> | |
<urn1:account>ACC_ID</urn1:account> | |
<urn1:consumerKey>CON_KEY</urn1:consumerKey> | |
<urn1:token>TO_ID</urn1:token> | |
<urn1:nonce>NONCE</urn1:nonce> | |
<urn1:timestamp>TIMESTAMP</urn1:timestamp> | |
<urn1:signature algorithm="HMAC_SHA256">COMPUTED_KEY</urn1:signature> | |
</urn:tokenPassport> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task getData() | |
{ | |
var oAuth1 = OAuth1Authenticator.ForAccessToken( | |
consumerKey: CONSUMER_KEY, | |
consumerSecret: CONSUMBER_SECRET, | |
token: TOKEN_ID, | |
tokenSecret: TOKEN_SECRET, | |
OAuthSignatureMethod.HmacSha256 | |
); |