SOAP Integration with NetSuite via Postman

SOAP Integration with NetSuite(Postman)


This blogs help you in creating integration with Netsuite via SOAP webservices request(Suitetalk).


Pre-requisites:

1. Find appropriate WSDL as per your sandbox version.

    Example: https://XXXXXX.suitetalk.api.netsuite.com/services/NetSuitePort_2020_1

2. Must have Postman or similar type of tool to test out your integration.

3. Take a note of ACCOUNT ID by going to Setup->Company->Company Information


Steps:

1 Create a role which will support SOAP web services integration.

    Under Setup section

    Role Should have below permissions.

    Login using access tokens

    SOAP webservices

    View SOAP webservices logs

    Under Transaction:

    Purchase Order
Sales Order

2 Create Employee and assign new role to this user.

3. Create Integration by Setup->Integration->Manage Integrations

(Note down the customer Key and Consumer Secret for future reference)

4 Create access token for this new integration created in previous steps along with role and employee.

(Note down the Token ID and Token Secret for future reference)



Steps in Postman or other related tool

1. In url paste WSDL : https://XXXXXX.suitetalk.api.netsuite.com/services/NetSuitePort_2020_1

2. Create new Environment in postman because this helps you in setting environment variables which will be used in setting a connection with netsuite.



3. Under Auth: No Auth.

4. Under Headers:

Content-type text/xml

 SOAPAction add

(add -to add a new transaction)

5. Adda Pre-request script like below:


let account = pm.environment.get("ACCOUNT");

let consumerKey = pm.environment.get("CONSUMER_KEY");
let consumerSecret = pm.environment.get("CONSUMER_SECRET");
let tokenId = pm.environment.get("TOKEN_ID");
let tokenSecret = pm.environment.get("TOKEN_SECRET");
  
console.log('tokenSecret'+tokenSecret)  ;
let timestamp = new Date().getTime().toString().substring(010); let nonce = CryptoJS.lib.WordArray.random(10).toString(); let baseString = account + '&' + consumerKey + '&' + tokenId + '&' + nonce + '&' + timestamplet key = consumerSecret + '&' + tokenSecretlet signature = CryptoJS.HmacSHA256(baseStringkey).toString(CryptoJS.enc.Base64);

pm.environment.set("signature"signature);
pm.environment.set("nonce"nonce);
pm.environment.set("timestamp"timestamp);


6. Add Body in XML format

<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:platformCore="urn:core_2020_1.platform.webservices.netsuite.com">
    <soapenv:Header>
        <ns1:searchPreferences soapenv:mustUnderstand="0" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" xmlns:ns1="urn:messages.platform.webservices.netsuite.com">
            <ns2:bodyFieldsOnly xmlns:ns2="urn:messages_2020_1.platform.webservices.netsuite.com">false</ns2:bodyFieldsOnly>
            <ns3:returnSearchColumns xmlns:ns3="urn:messages_2020_1.platform.webservices.netsuite.com">false</ns3:returnSearchColumns>
            <ns4:pageSize xmlns:ns4="urn:messages_2020_1.platform.webservices.netsuite.com">30</ns4:pageSize>
        </ns1:searchPreferences>
        <ns5:tokenPassport soapenv:mustUnderstand="0" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" xmlns:ns5="urn:messages_2020_1.platform.webservices.netsuite.com">
            <ns6:account xmlns:ns6="urn:core_2020_1.platform.webservices.netsuite.com">{{ACCOUNT}}</ns6:account>
            <ns7:consumerKey xmlns:ns7="urn:core_2020_1.platform.webservices.netsuite.com">{{CONSUMER_KEY}}</ns7:consumerKey>
            <ns8:token xmlns:ns8="urn:core_2020_1.platform.webservices.netsuite.com">{{TOKEN_ID}}</ns8:token>
            <ns9:nonce xmlns:ns9="urn:core_2020_1.platform.webservices.netsuite.com">{{nonce}}</ns9:nonce>
            <ns10:timestamp xmlns:ns10="urn:core_2020_1.platform.webservices.netsuite.com">{{timestamp}}</ns10:timestamp>
            <ns11:signature algorithm="HMAC_SHA256" xmlns:ns11="urn:core_2020_1.platform.webservices.netsuite.com">{{signature}}</ns11:signature>
        </ns5:tokenPassport>
    </soapenv:Header>
    <soapenv:Body>
        <add>
                <record xsi:type="tranPurch:PurchaseOrder" xmlns:tranPurch="urn:purchases_2020_1.transactions.webservices.netsuite.com">
                    <entity internalId="1533555"/>
                    <location xsi:type="urn:RecordRef" internalId="67"/>
                    
                    <itemList>
                        <item>
                            <item internalId="1419"/>
                            <quantity>1</quantity>
                            <department>11000 - Accounting</department>
                            <department xsi:type="platformCore:RecordRef" internalId="125"/>
                            <class xsi:type="platformCore:RecordRef" internalId="105"/>
                            <location xsi:type="platformCore:RecordRef" internalId="67"/>
                        </item>
                    </itemList>
                    <customFieldList  xsi:type="platformCore:CustomFieldList">
                    <customField xsi:type="platformCore:StringCustomFieldRef" internalId="1891">
                    <value xsi:type="xsd:string">values</value>
                    </customField>
                    <customField xsi:type="platformCore:SelectCustomFieldRef" internalId="1876">
                    <value xsi:type="platformCore:ListOrRecordRef" internalId="23"/>
                    </customField>
                    </customFieldList>    

                </record>
            </add>
    </soapenv:Body>
</soapenv:Envelope>


7. Hereafter you will get response that Purchase order is created.


Hints/Issues:

You might face below errors and you can deal with them by:
1. Invalid Login: Must be issue with token details
2. Invalid type CustomFieldList: For this make sure you have mentioned below line at the top of SOAP xml this will include the core library
xmlns:platformCore="urn:core_2020_1.platform.webservices.netsuite.com"


Abhijeet Godse
TechEnthusiast