你的位置:首页 > ASP.net教程

[ASP.net教程].NET invoke NetSuite Restlet


Please indicate the source if you need to repost.

Restlet allows programmers to use the http request instead of SuietTalk.

Below is the sample code for .NET coder to begin with:

    private void button1_Click(object sender, EventArgs e)    {      string myUrl = your_restlet_url;      HttpWebRequest request = HttpWebRequest.Create(myUrl) as HttpWebRequest;      request.ContentType = "application/json";      // Account: setup>integration>Web Services Preferences: Account ID      // Email: your NetSuite login email      // Signature: NetSuite login password      // Role: admin = 3      request.Headers.Add("Authorization:NLAuth nlauth_account=1005259,nlauth_email=xxx@netsuite.com,nlauth_signature=,nlauth_role=3");      request.Method = "POST";      string myParam = "{\"mydata1\":1234,\"mydata2\":2345}";      using (var streamWriter = new StreamWriter(request.GetRequestStream()))      {        streamWriter.Write(myParam);      }      HttpWebResponse response = request.GetResponse() as HttpWebResponse;    }

.NET Sample Code

 

Below is the sample code of Restlet:

function restlets_post(datain) {  try {    nlapiLogExecution('debug', 'restlets_get', datain.mydata2);    var mystring='{"data1":123,"data2":234}';    var myJson=parseJSON(mystring);    return myJson;  }  catch (ex) {    nlapiLogExecution('debug', 'restlets_post', ex);  }}

Restlet Code

 

Hope it helps the life of SuiteTalk developer.