Looks like C# code and you've posted to the Visual Basic forum.
Anyway, an error 500 means that there is a problem accessing the resource in the web request. There could be many reasons for this so I would verify that the web request is correct first and if it continues to fail then the resource (web page?) needs to
be fixed before your code will function.
Visual C# forum
Paul ~~~~ Microsoft MVP (Visual Basic)