SOAP REQUEST IN POSTMAN

Hey everyone, since a few days I’ve been trying to make soap request to create/update/delete transactions in Netsuite using Postman or SoapUI. I’ve failed every time so, I need to know if someone have tips or a tutorial to share with me. I can’t explain the error because every time I get a different error.

Anyway,  here is the request I’m using in Postman:

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap-env:Header>
    <tokenPassport xmlns="urn: messages_2021_1.platform.webservices.netsuite.com" xmlns:ns1="urn:core_2021_1.platform.webservices.netsuite.com">
      <account>{{ACCOUNT}}</account>
      <consumerKey>{{CONSUMER_KEY}}</consumerKey>
      <token>{{TOKEN_ID}}</token>
      <nonce>{{nonce}}</nonce>
      <timestamp>{{timestamp}}</timestamp>
      <signature algorithm="HMAC-SHA1">{{signature}}</signature>
    </tokenPassport>
    <preferences>
      <runServerSuiteScriptAndTriggerWorkflows>
        false
      </runServerSuiteScriptAndTriggerWorkflows>
    </preferences>
    <searchPreferences>
      <pageSize>1000</pageSize>
      <bodyFieldsOnly>false</bodyFieldsOnly>
    </searchPreferences>
  </soap-env:Header>
  <soap-env:Body>
   <urn:get xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:platformCore="urn:core_2021_1.platform.webservices.netsuite.com">
         <urn:baseRef internalId="46" type="invoice" xsi:type="platformCore:RecordRef">
        </urn:baseRef>
      </urn:get>
  </soap-env:Body>
</soap-env:Envelope>

And the pre-request script:

pm.collectionVariables.set("name_detail", pm.collectionVariables.get(" name")+"_vip");
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");
let timestamp = new Date().getTime().toString().substring(0, 10);
let nonce = CryptoJS.lib.WordArray.random(10).toString();
let baseString = `${account}&${consumerKey}&${tokenId}&${nonce}&${timestamp}`;
let key = `${consumerSecret}&${tokenSecret}`;
let signature = CryptoJS.HmacSHA1(baseString, key).toString(CryptoJS.enc.Base64);
pm.environment.set("signature", signature);
pm.environment.set("nonce", nonce);
pm.environment.set("timestamp", timestamp);

The endpoint is: https://myAccountID.suitetalk.api.netsuite.com/services/NetSuitePort_2021_1

Thanks!

Rookie Asked on January 25, 2022 in SuiteCloud.
Add Comment
1 Answer(s)

Hi Luken,

Any chance you could give us a sample of the errors so that we can try to determine whether it’s authentication or message issues?

I’ve not had chance to take a look at SOAP in Postman recently but I’ve successfully used the below setup script in SoapUI. And I’ve included the XML too.

Thanks,

Chris

import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
 
// ==================================================
// UPDATE THIS SECTION WITH YOUR DETAILS
// ==================================================
String account_id = '';
String consumer_key = '';
String consumer_secret = '';
String token = '';
String token_secret = '';
// ==================================================
 
String nonce = Math.random().toString().substring(2);
String timestamp = String.format("%.0f", Math.floor((new Date()).getTime() / 1000));
 
String base_string = account_id + '&' + consumer_key + '&' + token + '&' + nonce + '&' + timestamp;
String signing_key = consumer_secret + '&' + token_secret;
 
SecretKeySpec secret_key_spec = new SecretKeySpec(signing_key.getBytes(), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(secret_key_spec);
byte[] signature_bytes = mac.doFinal(base_string.getBytes());
String signature = signature_bytes.encodeBase64();
 
testRunner.testCase.setPropertyValue( "Account", account_id );
testRunner.testCase.setPropertyValue( "ConsumerKey", consumer_key );
testRunner.testCase.setPropertyValue( "ConsumerSecret", consumer_secret );
testRunner.testCase.setPropertyValue( "Token", token );
testRunner.testCase.setPropertyValue( "TokenSecret", token_secret );
testRunner.testCase.setPropertyValue( "Nonce", nonce );
testRunner.testCase.setPropertyValue( "Timestamp", timestamp );
testRunner.testCase.setPropertyValue( "Signature", signature );
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:platformMessages="urn:messages_2018_1.platform.webservices.netsuite.com" xmlns:platformCore="urn:core_2018_1.platform.webservices.netsuite.com">
<soapenv:Header>
<platformMessages:tokenPassport>
<platformCore:account>${#TestCase#Account}</platformCore:account>
<platformCore:consumerKey>${#TestCase#ConsumerKey}</platformCore:consumerKey>
<platformCore:token>${#TestCase#Token}</platformCore:token>
<platformCore:nonce>${#TestCase#Nonce}</platformCore:nonce>
<platformCore:timestamp>${#TestCase#Timestamp}</platformCore:timestamp>
<platformCore:signature algorithm="HMAC-SHA1">${#TestCase#Signature}</platformCore:signature>
</platformMessages:tokenPassport>
</soapenv:Header>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
Intermediate Answered on January 26, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor