This exception is thrown when I need to call the Registry of my project and get all services displayed in client.It worked yesterday but dont know why its not working now.Can anyone help with me with this?
This is my method to get all services to client from the registry api
private void btnGetAll_Click(object sender, RoutedEventArgs e)
{
Services services;
User user = User.Instance;
//Api Call is made.
string url = "http://localhost:14470/api/AllServies/ " + Rtoken;
var clinet = new RestClient(url);
var request = new RestRequest();
var response = clinet.Post(request);
List<Services> data = new List<Services>();
data = JsonConvert.DeserializeObject<List<Services>>(response.Content.ToString());
List<Services> gridData = new List<Services>();
foreach (Services line in data)
{
//services = JsonConvert.DeserializeObject<List<Services>>(line);
/*if (services.Status.Equals("Denied"))
{
logout();
break;
}*/
gridData.Add(line);
}
// Services test = serviceInfo.SelectedItem as Services;
serviceInfo.ItemsSource = gridData;
}
This is the all service controller of my registry api
// POST: api/AllServices
[Route("api/AllServies/{token}")]
[HttpPost]
public IHttpActionResult Post([FromBody] int token)
{
//AuthInterface foob = auth.initServerConnection();
// Ilist return for returning list with multple types
//token validation
string validate = foob.Validate(token);
if (validate.Equals("Not Validated"))
{
//if valid token
// path to the text file
string path = "C:\\Users\\ravin\\Desktop\\assignment_1_DC\\Services.txt";
List<string> services = File.ReadAllLines(path).ToList();
List<Rdetails> regservice = new List<Rdetails>();
//checking for every line
foreach (var service in services)
{
//deserlizing text and assigning values to RegistryDetail type object
Rdetails rDetail = JsonConvert.DeserializeObject<Rdetails>(service);
// add details to the created Registry details type list
regservice.Add(rDetail);
}
return Ok(regservice);
}
else
{
// if token is unvalid
Rresponse reg = new Rresponse();
reg.RegStatus = "Denied";
reg.RegReason = "Authentication Error";
List<Rresponse> output = new List<Rresponse>();
output.Add(reg);
return Ok(output);
}
}
}
}