'WebClient is not sending the form parameters correctly?

If I use Nightingale REST Client to download a CSV file it works, but if I try to duplicate the configuration and get the file using VB.Net it fails.

Here is a screencap of my Nightingale config and a successful response:

Screencap

This is my code to try and do the same thing:

    Dim values As NameValueCollection
    Dim result As Byte()
    Using client = New WebClient()
        client.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
        values = New NameValueCollection From {{"_EVENTARGUMENT", "CSV,Export,,M"}, {"_EVENTTARGET", "dnn$ctr520$dnn"}, {"txtFlt_AI", ""}, {"txtFlt_CoName", ""}, {"cboFlt_ParishName", ""}, {"cboFlt_Fyear", ""}, {"ScrollTop", ""}}
        result = client.UploadValues("https://internet.deq.louisiana.gov/portal/DIVISIONS/UNDER-GROUND-STORAGE-TANK/CURRENT-UST-TANK-CERTIFICATES", "POST", values)
    End Using

Instead of the CSV file, I get the web page that this URL normally retrieves. What am I missing here? Thanks.



Solution 1:[1]

hard to tell from just this info, i'd say make sure you have all your headers input, and you might have to set the user agent, and perhaps along with it, the referrer.

also look into your auth, if you receive any sort of token or cookie, you'll need to store and pass that along too.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 drpepper1324