Get a REST URL in VB.NET

Print this topicEmail this topicSave as PDF

The example below demonstrates how to obtain a REST URL while using VB.NET.

Product: 
Unlimited
Enterprise
Trial
Community
On-Premise
Application Code: 
Imports System
Imports System.IO
Imports System.Net
Imports System.Text


Public Class Form1
    Private Sub btntestrest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btntestrest.Click

         
        addtoText("Starting")

        'Setup the URL to get
        Dim s_rallyurl As String = "https://rally1.rallydev.com:443/slm/webservice/1.10/rss/task?title=Blocked Tasks&query=((Blocked = true) and (State != Completed))&order=Rank"

        '
Setup the authenication info

        Dim rallyrequest As WebRequest = WebRequest.Create(s_rallyurl)
        rallyrequest.PreAuthenticate = True
        Dim rallyuser As String = "myuser@company.com"
        Dim rallypass As String = "rallypassword"
        Dim rallycredentials As New NetworkCredential(rallyuser, rallypass)
        rallyrequest.Credentials = rallycredentials

        Dim s_update As String = ""       'make the call
        Dim rallyresponse As HttpWebResponse = CType(rallyrequest.GetResponse(), HttpWebResponse)

        addtoText(rallyresponse.StatusDescription)
        Dim mydatastream As Stream = rallyresponse.GetResponseStream()
        Dim myreader As New StreamReader(mydatastream)
        Dim myanswer As String = myreader.ReadToEnd()
        addtoText(myanswer)
        myreader.Close()
        mydatastream.Close()
        rallyresponse.Close()

        addtoText("closed")
    End Sub

    Private Sub addtoText(ByVal linetoAppend)
        Dim mymessage As String = vbCrLf
        mymessage = mymessage & linetoAppend
        RichTextBox1.AppendText(mymessage)
    End Sub
End Class
© 2012 Rally Software Development Corp | Legal