Posting to an API, using a DB call RRS feed

  • Question

  • User1428409250 posted

    If this is the wrong forum, forgive me.  I have been asked to develop an automated program to query a DB once a day and upload the contents to a Java Based API.  I have found that by doing a standard form and submitting the info,it works (using a traditional submit button).  However, when this process is automated and repeated back to back as quick as the Data comes in from a DB, it chokes. 

    On my VB.net side I am using the httpwebrequest to post the info and as I said, when doing one at a time, it works. 

    Does anyone have a suggestion as to the best way to go about doing this from a Windows APplication to a Web Form?  Would the webrequest or httpwebrequest work for this instance?  Not looking for anything but some help in the right direction.

    Here is my code for example that is from my Windows Application:


    Dim request As WebRequest

    request = CType(HttpWebRequest.Create("http://somewebsite/add/index.jsp"), HttpWebRequest)

    Dim response As HttpWebResponse

    Dim strPost As String


    String="string information consisting of a db record or form control like a textbox.text"

    Dim encoding As New UTF8Encoding

    Dim bytes As Byte() = encoding.GetBytes(strPost)

    request.Method = "POST"

    request.ContentType = "application/x-www-form-urlencoded"

    request.ContentLength = bytes.Length

    Dim newStream As Stream = request.GetRequestStream()

    newStream.Write(bytes, 0, bytes.Length)






    Wednesday, September 21, 2011 11:29 AM


  • User-952121411 posted

    Would the webrequest or httpwebrequest work for this instance?

    It should as the 'HttpWebRequest' class is in the System.Net namespace which is available to Windows Forms or any type of .NET project.

    Also, to automate the process all together so a user does not have to 'click a button' to fire off the process, try something like the following by using a Windows Service:

    Running a Periodic Process in .NET using a Windows Service:


    As far as the quick repetition causing it to choke, if you were to implement the method above, try setting the interval to something like every 30 seconds and then reduce until you find a threshold that causes the issue. Then you could debug that specific exception to see why the exception is occurring.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 21, 2011 3:01 PM