title: .NET Framework 4 VB.Net Call an API
body: <p>I am working in an "old" VB.Net application. I wish to make a call to an API, check if I got a <code>404</code>, parse the JSON result and all the other usual things you can do with an API call.</p>
  
  <p>What is the cleanest way of doing this? I thought I can use the <a href="https://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.110).aspx" rel="nofollow noreferrer">HttpClient</a> class, but I can't apparently! VS 2017 is not giving me the option of adding <code>System.Net.Http</code> as an Import.</p>
  
  <p><strong>CODE</strong></p>
  
  <p>Right now I'm doing this which seems messy.</p>
  
  <pre><code>Public Function GetUserInfo(ByVal authTokenBytes As Byte()) As WebPayWS.GetUserInfoResult
    Dim token As New token
    token.token1 = authTokenBytes
    Dim userInformation As GetUserInfoResult = _myService.GetUserInfo(token)
    If AccountExists(userInformation.accountno) Then
      Dim response As String = GetAccountInfoFromApi(userInformation.accountno)
    End If
    Return userInformation
  End Function
  
  Private Function GetAccountInfoFromApi(accountno As String) As String
    Dim accountInformationUrl As String = "URL"
    Dim webClient As WebClient = New WebClient()
    Return webClient.DownloadString(New Uri(accountInformationUrl))
  End Function
  </code></pre>
  
  <p>Am I stuck with <code>WebClient</code>? If yes, how do I check for a <code>404</code> using WebClient?</p>