0

Hello I have an api which authenticates the user login . Now when I hit this rest service in my browser it displays the result but when I try to do this using my code it gives in 500 error. Please help me with this .

My Api: http://abhinavevent2014.sched.org/api/auth/login?api_key=1309658400d57c8cfc6081f8361de52c&username=abhinavm@test.com&password=test

string url = @"http://abhinavevent2014.sched.org/api/auth/login?api_key=1309658400d57c8cfc6081f8361de52c&username=abhinavm@test.com&password=test";


            Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
            WebRequest requestfriend = WebRequest.Create(url);
            WebResponse responsefriend = requestfriend.GetResponse(); (  This is where it blows)
            Stream streamResponse = responsefriend.GetResponseStream();
            StreamReader streamReaderResponse = new StreamReader(streamResponse, encode);
            jsonResult = streamReaderResponse.ReadToEnd();

            return jsonResult.ToString();
pnuts
  • 58,317
  • 11
  • 87
  • 139

1 Answers1

0

You need to use User-Agent in the headers, as the documentation says:

You must also send requests with a User-Agent in the headers, as Sched filters out requests with no User-Agent. Sched API Doc

Browser automatically does that, so it can retrieve the data.

thur
  • 964
  • 1
  • 15
  • 27