BennoDual
BennoDual

Reputation: 6259

Call http url (php) generates always WebException

I can call the following url in a browser and it works:

http://test.shop.ch/shop/Admin/caller/caller_aufruf.php?do=set_kategorien

It does not give soemthing back - only execute the php.

But when I try to call the same with C# like

using (var client = new WebClient()) {
    var uri = new Uri("http://test.shop.ch/shop/Admin/caller/caller_aufruf.php?do=set_kategorien");
    cResponse = client.DownloadString(uri);
}

I always get a WebException:

The request failed with HTTP status 401: Unauthorized.

Can someone help me, what I am doing wrong? - Thanks.

Upvotes: 0

Views: 88

Answers (1)

Matas Vaitkevicius
Matas Vaitkevicius

Reputation: 61351

Status code 401 that you are getting is indicating that you do not have permissions.
Which means that before you can call setcategory you need to obtain a token (or cookie) by calling login page, or send it in headers or whatever mechanism of authentication is used on your shop site and only then you can call setcategory.

Upvotes: 1

Related Questions