Example to post data to netsuite url

Hello Experts
I wanted to write a windows applicaion using vb.net to post data to the netsuite url. I am trying to some example code which I can use to post data to URL.
Can someone advise?
Thanks
Kh
faisalkhAsked:
Who is Participating?
 
newbie27Commented:
Hi
I have some example code in C#, I am sure you can easily convert into VB
using System;
using System.Net;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //URL includes the query string for the internal id for the record to be updated and the phone that will be used for the record update
            Uri url = new Uri("https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=97&deploy=1&compid=TSTDRV799164&h=fda074e46d984a31121e&internalid=162&phone=999-999-9999");


            HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);


            myHttpWebRequest.Method = "POST"; // Set method POST or GET
            myHttpWebRequest.UserAgent = "Mozilla/5.0"; // Set the user agent which is the type of browser
            myHttpWebRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8"; // Set the Content type
        


            // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
            // Calls the Suitelet which will process and process the response
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();


            // Retrieves the response from the Suitelet 
            Stream streamResponse = myHttpWebResponse.GetResponseStream();
            
            StreamReader streamRead = new StreamReader(streamResponse);
            Char[] readBuff = new Char[256];
            int count = streamRead.Read(readBuff, 0, 256);


            //Write the response on the console
            Console.WriteLine("Suitelet Response :\n");            
            while (count > 0)
            {
                String outputData = new String(readBuff, 0, count);
                Console.Write(outputData);
                count = streamRead.Read(readBuff, 0, 256);
            }
            // Release the response object resources.
            streamRead.Close();
            streamResponse.Close();
            myHttpWebResponse.Close();
        }
    }
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.