Somehow when using Windows mode, I get an Exception Error"Reference to undeclared entity 'nbsp'. Line 69, position 41."" weird. Then when I check the result.Content after executing I get like an html page with errors like 401 - Unauthorized: Access is denied due to invalid credentials. This is an issue that happens on the IIS Server too.

Below is my RestSharp Code from ActionResult

var client = new RestClient(Request.Url.GetLeftPart(UriPartial.Authority).ToString());
var request = new RestRequest("http://domain.co.za/api/student/getBookedSlotHistory", Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddObject(new StudentInput()
{
    StudentNumber = "219193029"//UserIdentity.Username()
});

var result = client.Execute<StudentBookingHistoryOutput>(request);
var data = JsonConvert.DeserializeObject<StudentBookingHistoryOutput>(result.Content);

Then below is my APIController

[HttpPost]
[Route("api/student/getBookedSlotHistory")]
public async Task<StudentBookingHistoryOutput> GetHistory(StudentInput input)
{
    return await _studentRepository.GetBookingHistoryData(input);
}

1 Answers

1
Anele Ngqandu On

This actually solved my problem.

request.UseDefaultCredentials = true;