francis
09/15/2021, 8:25 AMstatic void Main(string[] args)
{
JournalEntry newJournalEntry = new JournalEntry();
RecordRef subsidiaryRef = new RecordRef();
subsidiaryRef.name = "Optiver Holding Group : Optiver Holding BV : APAC : Optiver Asia Trading BV : Optiver Taiwan Futures Co. Limited";
newJournalEntry.subsidiary = subsidiaryRef;
RecordRef currencyRef = new RecordRef();
currencyRef.name = "TWD";
newJournalEntry.currency = currencyRef;
newJournalEntry.tranDate = new DateTime(2021, 7, 06);
newJournalEntry.memo = "FOPA_TaiwanMM_07_2021";
newJournalEntry.lineList = new JournalEntryLineList();
newJournalEntry.lineList.line = new JournalEntryLine[2];
RecordRef debitAccountRef = new RecordRef();
debitAccountRef.externalId = "40134601";
RecordRef creditAccountRef = new RecordRef();
creditAccountRef.externalId = "20614602";
RecordRef costCenterRef = new RecordRef();
costCenterRef.name = "Trading";
RecordRef profitCenterRef = new RecordRef();
profitCenterRef.name = "Option Taiwan";
RecordRef locationRef = new RecordRef();
locationRef.name = "Taiwan";
SelectCustomFieldRef categoryRef = new SelectCustomFieldRef();
categoryRef.scriptId = "cseg_category";
categoryRef.value = new ListOrRecordRef();
categoryRef.value.name = "TWD";
SelectCustomFieldRef taxStatusRef = new SelectCustomFieldRef();
taxStatusRef.scriptId = "cseg_apac_taxstatus";
taxStatusRef.value = new ListOrRecordRef();
taxStatusRef.value.name = "GENERAL";
newJournalEntry.lineList.line[0] = new JournalEntryLine();
newJournalEntry.lineList.line[0].account = debitAccountRef;
newJournalEntry.lineList.line[0].memo = "Memo Test";
newJournalEntry.lineList.line[0].department = costCenterRef;
newJournalEntry.lineList.line[0].location = locationRef;
newJournalEntry.lineList.line[0].@class = profitCenterRef;
newJournalEntry.lineList.line[0].debit = 1000;
newJournalEntry.lineList.line[0].debitSpecified = true;
newJournalEntry.lineList.line[0].customFieldList = new CustomFieldRef[2];
newJournalEntry.lineList.line[0].customFieldList[0] = categoryRef;
newJournalEntry.lineList.line[0].customFieldList[1] = taxStatusRef;
newJournalEntry.lineList.line[1] = new JournalEntryLine();
newJournalEntry.lineList.line[1].account = creditAccountRef;
newJournalEntry.lineList.line[1].memo = "Memo Test";
newJournalEntry.lineList.line[1].department = costCenterRef;
newJournalEntry.lineList.line[1].location = locationRef;
newJournalEntry.lineList.line[1].@class = profitCenterRef;
newJournalEntry.lineList.line[1].credit = 1000;
newJournalEntry.lineList.line[1].creditSpecified = true;
newJournalEntry.lineList.line[1].customFieldList = new CustomFieldRef[2];
newJournalEntry.lineList.line[1].customFieldList[0] = categoryRef;
newJournalEntry.lineList.line[1].customFieldList[1] = taxStatusRef;
TokenPassport passport = new TokenPassport();
passport.account = AccountID;
passport.consumerKey = ConsumerKey;
passport.token = Token;
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] data = new byte[20];
rng.GetBytes(data);
int value = Math.Abs(BitConverter.ToInt32(data, 0));
string nonce = value.ToString();
Console.WriteLine("Nonce is " + nonce);
passport.nonce = nonce;
Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
string timestamp = unixTimestamp.ToString();
Console.WriteLine("Timestamp is " + timestamp);
passport.timestamp = Convert.ToInt64(timestamp);
string baseString = AccountID + "&" + ConsumerKey + "&" + Token + "&" + nonce + "&" + timestamp;
string key = ConsumerSecret + "&" + TokenSecret;
Console.WriteLine("Base String is " + baseString);
Console.WriteLine("Signing Key is " + key);
string signature = "";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] keyByte = encoding.GetBytes(key);
byte[] messageBytes = encoding.GetBytes(baseString);
using (HMACSHA1 myhmacsha1 = new HMACSHA1(keyByte))
{
byte[] hashmessage = myhmacsha1.ComputeHash(messageBytes);
signature = Convert.ToBase64String(hashmessage);
}
Console.WriteLine("Computed Signature is " + signature);
TokenPassportSignature sign = new TokenPassportSignature();
sign.algorithm = "HMAC-SHA256";
sign.Value = signature;
passport.signature = sign;
NetSuitePortTypeClient service = new NetSuitePortTypeClient(NetSuitePortTypeClient.EndpointConfiguration.NetSuitePort, ServiceURL);
WriteResponse response;
service.add(passport, new ApplicationInfo(), new PartnerInfo(), new Preferences(), newJournalEntry, out response);
Console.WriteLine(response.ToString());
Console.WriteLine("Done");
}
Does anyone have any idea on why? do I need to do something else besides providing a token to the service? Edit: This is C#battk
09/15/2021, 8:37 AMfrancis
09/15/2021, 8:47 AMbattk
09/15/2021, 8:51 AMbattk
09/15/2021, 8:51 AMfrancis
09/15/2021, 8:57 AMfrancis
09/15/2021, 9:07 AMbattk
09/15/2021, 9:17 AMbattk
09/15/2021, 9:18 AMbattk
09/15/2021, 9:18 AMfrancis
09/15/2021, 9:54 AM{<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="<http://schemas.xmlsoap.org/soap/envelope/>">
<s:Header>
<Action s:mustUnderstand="1" xmlns="<http://schemas.microsoft.com/ws/2005/05/addressing/none>">add</Action>
<h:applicationInfo xmlns="urn:<http://messages_2021_1.platform.webservices.netsuite.com|messages_2021_1.platform.webservices.netsuite.com>" xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>" xmlns:xsd="<http://www.w3.org/2001/XMLSchema>" xmlns:h="urn:<http://messages_2021_1.platform.webservices.netsuite.com|messages_2021_1.platform.webservices.netsuite.com>" />
<h:partnerInfo xmlns="urn:messages_2021_1.platform.webservices.netsuite.com" xmlns:h="urn:messages_2021_1.platform.webservices.netsuite.com" />
<h:preferences xmlns="urn:messages_2021_1.platform.webservices.netsuite.com" xmlns:h="urn:messages_2021_1.platform.webservices.netsuite.com" />
<h:tokenPassport xmlns="urn:messages_2021_1.platform.webservices.netsuite.com" xmlns:h="urn:messages_2021_1.platform.webservices.netsuite.com">
<account xmlns="urn:core_2021_1.platform.webservices.netsuite.com"></account>
<consumerKey xmlns="urn:core_2021_1.platform.webservices.netsuite.com"></consumerKey>
<token xmlns="urn:core_2021_1.platform.webservices.netsuite.com"></token>
<nonce xmlns="urn:core_2021_1.platform.webservices.netsuite.com">1231775382</nonce>
<timestamp xmlns="urn:core_2021_1.platform.webservices.netsuite.com">1631699535</timestamp>
<signature algorithm="HMAC-SHA256" xmlns="urn:core_2021_1.platform.webservices.netsuite.com"></signature>
</h:tokenPassport>
</s:Header>
<s:Body xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>" xmlns:xsd="<http://www.w3.org/2001/XMLSchema>">
<add xmlns="urn:messages_2021_1.platform.webservices.netsuite.com">
<record xmlns:q1="urn:general_2021_1.transactions.webservices.netsuite.com" xsi:type="q1:JournalEntry">
<q1:currency>
<name xmlns="urn:core_2021_1.platform.webservices.netsuite.com">TWD</name>
</q1:currency>
<q1:subsidiary>
<name xmlns="urn:core_2021_1.platform.webservices.netsuite.com">Optiver Holding Group : Optiver Holding BV : APAC : Optiver Asia Trading BV : Optiver Taiwan Futures Co. Limited</name>
</q1:subsidiary>
<q1:memo>FOPA_TaiwanMM_07_2021</q1:memo>
<q1:lineList>
<q1:line>
<q1:account externalId="40134601" />
<q1:debit>1000</q1:debit>
<q1:memo>Memo Test</q1:memo>
<q1:department>
<name xmlns="urn:core_2021_1.platform.webservices.netsuite.com">Trading</name>
</q1:department>
<q1:class>
<name xmlns="urn:core_2021_1.platform.webservices.netsuite.com">Option Taiwan</name>
</q1:class>
<q1:location>
<name xmlns="urn:core_2021_1.platform.webservices.netsuite.com">Taiwan</name>
</q1:location>
<q1:customFieldList>
<customField xsi:type="SelectCustomFieldRef" scriptId="cseg_category" xmlns="urn:core_2021_1.platform.webservices.netsuite.com">
<value>
<name>TWD</name>
</value>
</customField>
<customField xsi:type="SelectCustomFieldRef" scriptId="cseg_apac_taxstatus" xmlns="urn:core_2021_1.platform.webservices.netsuite.com">
<value>
<name>GENERAL</name>
</value>
</customField>
</q1:customFieldList>
</q1:line>
<q1:line>
<q1:account externalId="20614602" />
<q1:credit>1000</q1:credit>
<q1:memo>Memo Test</q1:memo>
<q1:department>
<name xmlns="urn:core_2021_1.platform.webservices.netsuite.com">Trading</name>
</q1:department>
<q1:class>
<name xmlns="urn:core_2021_1.platform.webservices.netsuite.com">Option Taiwan</name>
</q1:class>
<q1:location>
<name xmlns="urn:core_2021_1.platform.webservices.netsuite.com">Taiwan</name>
</q1:location>
<q1:customFieldList>
<customField xsi:type="SelectCustomFieldRef" scriptId="cseg_category" xmlns="urn:core_2021_1.platform.webservices.netsuite.com">
<value>
<name>TWD</name>
</value>
</customField>
<customField xsi:type="SelectCustomFieldRef" scriptId="cseg_apac_taxstatus" xmlns="urn:core_2021_1.platform.webservices.netsuite.com">
<value>
<name>GENERAL</name>
</value>
</customField>
</q1:customFieldList>
</q1:line>
</q1:lineList>
</record>
</add>
</s:Body>
</s:Envelope>}
battk
09/15/2021, 10:01 AMbattk
09/15/2021, 10:01 AMbattk
09/15/2021, 10:03 AMbattk
09/15/2021, 10:11 AMfrancis
09/15/2021, 12:19 PMbattk
09/15/2021, 1:30 PMbattk
09/15/2021, 1:30 PMbattk
09/15/2021, 1:31 PMTravis Zuri
09/15/2021, 4:43 PMTravis Zuri
09/15/2021, 4:50 PM