Click here to Skip to main content
15,844,754 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Self Signed Cert Questions Pin
Kevin Marois9-Aug-22 13:12
professionalKevin Marois9-Aug-22 13:12 
GeneralRe: Self Signed Cert Questions Pin
Richard Deeming10-Aug-22 2:24
mveRichard Deeming10-Aug-22 2:24 
GeneralRe: Self Signed Cert Questions [UPDATED] Pin
Kevin Marois10-Aug-22 9:47
professionalKevin Marois10-Aug-22 9:47 
GeneralRe: Self Signed Cert Questions [UPDATED] Pin
Richard Deeming10-Aug-22 22:52
mveRichard Deeming10-Aug-22 22:52 
GeneralRe: Self Signed Cert Questions [UPDATED] Pin
Kevin Marois11-Aug-22 6:39
professionalKevin Marois11-Aug-22 6:39 
QuestionDisplay snowflake data into visualization format Pin
jebasgp20-Jul-22 2:51
jebasgp20-Jul-22 2:51 
AnswerRe: Display snowflake data into visualization format Pin
CHill6020-Jul-22 3:31
mveCHill6020-Jul-22 3:31 
Question.Net Framework Web API & Client - Empty JSON Pin
Kevin Marois11-Jul-22 17:56
professionalKevin Marois11-Jul-22 17:56 
I have this API controller method
[HttpGet]
public HttpResponseMessage GetPersonList(int personTypeId = 0, int clientRepId = 0)
{
    var response = new HttpResponseMessage();

    try
    {
        var data = Repository.GetPersonList(personTypeId, clientRepId);

        response = Request.CreateResponse(HttpStatusCode.OK, data);

        // AT THIS POINT THE RESPONSE HAS DATA&
    }
    catch (Exception e)
    {
        response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e);
    }

    return response;
}
It's working and has data, and when I call it from Postman I can see the complete JSON.

Here's my client:
public class APIExecutor
{
private HttpClient _client;

public APIExecutor(string baseAddress, HttpClient client = null)
{
    if (client != null)
    {
        _client = client;
    }
    else
    {
        _client = new HttpClient();
    }

    _client.BaseAddress = new Uri(baseAddress);
    _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}

public async Task<T> GetAsync<T>(string action, Dictionary<string, dynamic> parameters)
{
    T results = default(T);

    try
    {
        var queryString = CreateQueryString(action, parameters);

        HttpResponseMessage response = _client.GetAsync(queryString).Result;

        // FOR TESTING - RETURNS EMPTY JSON []
        var xxx = await response.Content.ReadAsStringAsync(); //<=== EMPTY JSON

        if (response.IsSuccessStatusCode)
        {
            // Status code is 200 here
            var responseString = await response.Content.ReadAsStringAsync();

            results = await ReadAsAsync<T>(response.Content);
        }
        else 
        {
            HandleException(response);
        }
    }
    catch (Exception e)
    {
        throw;
    }

    return results;
}

private async Task<T> ReadAsAsync<T>(HttpContent content)
{
    var results = JsonConvert.DeserializeObject<T>(await content.ReadAsStringAsync());

    return results;
}
}
Anyone see what's wrong?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: .Net Framework Web API & Client - Empty JSON Pin
Mycroft Holmes12-Jul-22 13:08
professionalMycroft Holmes12-Jul-22 13:08 
GeneralRe: .Net Framework Web API & Client - Empty JSON Pin
Kevin Marois 202212-Jul-22 13:36
Kevin Marois 202212-Jul-22 13:36 
AnswerRe: .Net Framework Web API & Client - Empty JSON Pin
Richard Deeming12-Jul-22 22:44
mveRichard Deeming12-Jul-22 22:44 
GeneralMessage Closed Pin
13-Jul-22 7:24
professionalKevin Marois13-Jul-22 7:24 
GeneralRe: .Net Framework Web API & Client - Empty JSON Pin
Richard Deeming13-Jul-22 7:55
mveRichard Deeming13-Jul-22 7:55 
GeneralRe: .Net Framework Web API & Client - Empty JSON Pin
Kevin Marois13-Jul-22 9:14
professionalKevin Marois13-Jul-22 9:14 
QuestionVisual Studio 2022 vs Visual Studio Code for Angular development Pin
Danpeking10-Jun-22 0:20
Danpeking10-Jun-22 0:20 
AnswerRe: Visual Studio 2022 vs Visual Studio Code for Angular development Pin
thatraja2-Aug-22 2:48
professionalthatraja2-Aug-22 2:48 
AnswerRe: Visual Studio 2022 vs Visual Studio Code for Angular development Pin
Jeremy Falcon15-Dec-22 14:14
professionalJeremy Falcon15-Dec-22 14:14 
AnswerRe: Visual Studio 2022 vs Visual Studio Code for Angular development Pin
Nitin S11-Apr-23 19:14
professionalNitin S11-Apr-23 19:14 
QuestionSearch Function Pin
Yhanzoe Adigue6-Jun-22 17:28
Yhanzoe Adigue6-Jun-22 17:28 
AnswerRe: Search Function Pin
Pete O'Hanlon6-Jun-22 21:41
subeditorPete O'Hanlon6-Jun-22 21:41 
QuestionI'm trying to interact with a select element with selenium Pin
lucas lima 202229-May-22 14:25
lucas lima 202229-May-22 14:25 
AnswerRe: I'm trying to interact with a select element with selenium Pin
behruz1230-Jul-22 20:40
behruz1230-Jul-22 20:40 
QuestionNew MVC5 project, Bootstrap update, Fail Pin
#realJSOP26-May-22 5:41
mve#realJSOP26-May-22 5:41 
AnswerRe: New MVC5 project, Bootstrap update, Fail Pin
Richard Deeming26-May-22 22:41
mveRichard Deeming26-May-22 22:41 
AnswerRe: New MVC5 project, Bootstrap update, Fail Pin
Matthew Dennis27-May-22 5:18
sysadminMatthew Dennis27-May-22 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.