Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to call Rest api see http://developer.sheerid.com/docs/affiliationType/listAffiliationTypes.html[^]


If i am calling this through curl command like this:

curl -3 -H "Authorization: Bearer 624a3eef46f79772958693fa87118b29" https://services-sandbox.sheerid.com/rest/0.5/affiliationType -k >ListAffiliationTypes.html pause

OUTPUT i get in application/json format:

["STUDENT_FULL_TIME","STUDENT_PART_TIME","FACULTY","EMPLOYEE","RESELLER","NON_PROFIT","ACTIVE_DUTY","VETERAN","MILITARY_FAMILY","MEMBER"]


Now i want to implement in asp.net C#. So that i could get all response in dropdown.

and use them further. I dont have any idea .. Please help me to solve issue..

I have tried following way to call..But it gives me the html format of SheerId Login Page

string sBaseUrl ="https://services-sandbox.sheerid.com/rest/0.5/ping[^]";
if (sBaseUrl != "")
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sBaseUrl);
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
dvResult.InnerHtml = reader.ReadToEnd();
}
else
{
dvResult.InnerHtml = "Please Enter base URL";
}
Posted
Updated 13-Mar-13 20:50pm
v4

Use HttpWebRequest class, it allows you to add custom headers to http request and choose http method.
 
Share this answer
 
I have Solved it..

string sBaseUrl = txtBaseUrl.Text;
if (sBaseUrl != "")
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sBaseUrl);
request.Method = "GET";
request.UnsafeAuthenticatedConnectionSharing = true;
request.Headers["Authorization"] = "Bearer 624a3eef46f79772958693fa87118b29";
request.Credentials = new NetworkCredential("mrinalkumarjha", "*******");

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
dvResult.InnerHtml = reader.ReadToEnd();
}
else
{
dvResult.InnerHtml = "Please Enter base URL";
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900