I am writing some software in VB.NET to trade through the API. I have sample code from Prosper that I have adapted, but it throws an 'unauthorized' error when I request files from the Prosper servers. THe username and password are correct (and are specifically for API requests).
Prosper doesn't have the resources to explain why their sample code doesn't work. Does anyone here have ideas? Here's the code:
sub PROSPER()
Try
Dim ListingsURL, listing As String
ListingsURL = "
https://api.prosper.com/api/Listings?$top=3"
Using client = New System.Net.WebClient()
client.Credentials = New System.Net.NetworkCredential(txtSettingsUsername.Text, txtSettingsPassword.Text)
client.UseDefaultCredentials = False
client.Headers.Add(System.Net.HttpRequestHeader.Accept, "text/csv") 'specify file type to download
Using reader = New IO.StreamReader(client.OpenRead(ListingsURL)) '===> THIS THROWS A 401/UNAUTHORIZED ERROR
reader.ReadLine() 'wipe out the header
While (InlineAssignHelper(listing, reader.ReadLine())) IsNot Nothing
Console.WriteLine(listing)
End While
End Using
End Using
Catch ex As SystemException
MsgBox(ex.Message)
End Try
end sub