其他分享
首页 > 其他分享> > .NET invoke NetSuite Restlet

.NET invoke NetSuite Restlet

作者:互联网

原文链接:http://www.cnblogs.com/caidaniel/p/5543350.html

Please indicate the source if you need to repost.

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

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.

转载于:https://www.cnblogs.com/caidaniel/p/5543350.html

标签:invoke,Restlet,request,HttpWebRequest,NET,com,nlauth
来源: https://blog.csdn.net/weixin_30519071/article/details/98443790