Hi all, I'm using the https module in SS2.0, and a...
# suitescript
d
Hi all, I'm using the https module in SS2.0, and attempting to make a POST request to a 3rd party server, however the body of the request is not being received by the server. Based on what I can see in the logs of my 3rd party server, it seems that the body is being stripped between my call to https.post and the request actually being sent from the NetSuite account. I've tested making the same call to a different server, and it works as expected, so I suspect that there's a configuration setting I need to have updated. Anyone had this issue in the past, or have any ideas?
b
Probably should share your code
But the only way you could get a different body is if you are using guids
d
Sure, here it is:
/**
 
* @NApiVersion 2.x
 
* @NScriptType UserEventScript
 
* @NModuleScope SameAccount
 
*/
define(['N/https'],
  
function (https) {
    
/**
     
* Function definition to be triggered before record is loaded.
     
*
     
* @param {Object} scriptContext
     
* @param {Record} scriptContext.newRecord - New record
     
* @param {Record} scriptContext.oldRecord - Old record
     
* @param {string} scriptContext.type - Trigger type
     
* @Since 2015.2
     
*/
    
function afterSubmit(scriptContext) {
      
var headers1 = [];
      
headers1['Content-Type'] = 'application/json';
      
var body1 = JSON.stringify({
        
name: 'John',
        
email:<mailto:'john@example.com|'john@example.com>',
        
job: 'developer'
      
});
      
var postRequest = <http://https.post|https.post>({
        
url: '<https://third.party.server.com/api/>',
        
body: body1,
        
headers: headers1
      
}); // The body is left empty by the time the request is received at the 3rd party server (per logs on said server)
    
}
    
return {
      
afterSubmit: afterSubmit
    
};
  
}
);
b
looks normal to me
might want to try something like postman to make the request and see what the logs look like
and make the code in suitescript match if it works
d
That's what I thought, it's not complicated code by any means. Thanks for the suggestion re: Postman, I'll give that a go
d
Try sending your posts to https://requestcatcher.com/
Its a very useful tool to see exactly what you are sending out of NetSuite