To invoke an HTTP 'GET' method to a Restlet to retrieve a customer record, use the following code as guide:
Restlet code:
function getCustomer(customerID){
var rec;
if(customerID != null && customerID != ""){
rec = nlapiLoadRecord('customer',customerID.customerID);
}
return rec;
}
C# code snippet:
string recordID = "87"; //Internal ID of customer record
string url = "https://rest.netsuite.com/app/site/hosting/restlet.nl?script=20&deploy=1"; //URL of Restlet
url += "&customerID=" + recordID; //add the internal ID as parameter
//build the Authorization header string
string authHeader = "Authorization:NLAuth nlauth_account=1234567,";
authHeader += "nlauth_email=email@netsuite.com,";
authHeader += "nlauth_signature=password,nlauth_role=3";
//create the web request
WebRequest request = WebRequest.Create(url);
//set the request parameters
request.ContentType = "application/json";
request.Method = "GET";
request.Headers.Add(authHeader);
//get the response
WebResponse response = request.GetResponse();
1.The name of the parameter you set in the request url should match the name of the restlet's parameter (ie. 'customerID').
2. You cannot put data in the request body if the method is set to 'GET'.
No comments:
Post a Comment