logo

ASP.NET - How to call a restful service using httpwebrequest and httpwebresponse

Overview: This code snippet demonstrates how to call the login restful service called login_information using the httpwebrequest object and adding xml header information for credentials.
        Dim sUrl As String = "https://demo.docusign.net/restapi/v1/login_information?

api_password=true&include_account_id_guid=true&login_settings=all"

        Dim oRequest As HttpWebRequest
        oRequest = WebRequest.Create(sUrl)
        oRequest.KeepAlive = False
        oRequest.Method = "GET"
      
        oRequest.Headers.Add("X-DocuSign-Authentication",
            String.Format("<DocuSignCredentials><Username>{0}</Username><Password>{1}</Password><IntegratorKey>

{2}</IntegratorKey></DocuSignCredentials>", "abc@gmail.com", "mypassword", "myintegrator-code"))
       
        Dim oResponse As HttpWebResponse = oRequest.GetResponse
s