0

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.

BennoDual
  • 5,865
  • 15
  • 67
  • 153
  • The issue is the `401 Unauthorized`, it expects there to be headers sent for basic authentication and you fail to supply them. – Ohgodwhy Jul 04 '14 at 17:05
  • A wild guess would be that the server authorizes only for standard browsers. May be you need to try and replicate the exact request. – PCoder Jul 04 '14 at 17:07

1 Answers1

1

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.

Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265