Click here to Skip to main content
15,443,981 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Self Signed Cert Questions Pin
Kevin Marois9-Aug-22 12:12
professionalKevin Marois9-Aug-22 12:12 
GeneralRe: Self Signed Cert Questions Pin
Richard Deeming10-Aug-22 1:24
mveRichard Deeming10-Aug-22 1:24 
GeneralRe: Self Signed Cert Questions [UPDATED] Pin
Kevin Marois10-Aug-22 8:47
professionalKevin Marois10-Aug-22 8:47 
GeneralRe: Self Signed Cert Questions [UPDATED] Pin
Richard Deeming10-Aug-22 21:52
mveRichard Deeming10-Aug-22 21:52 
GeneralRe: Self Signed Cert Questions [UPDATED] Pin
Kevin Marois11-Aug-22 5:39
professionalKevin Marois11-Aug-22 5:39 
QuestionDisplay snowflake data into visualization format Pin
jebasgp20-Jul-22 1:51
Memberjebasgp20-Jul-22 1:51 
AnswerRe: Display snowflake data into visualization format Pin
CHill6020-Jul-22 2:31
mveCHill6020-Jul-22 2:31 
Question.Net Framework Web API & Client - Empty JSON Pin
Kevin Marois11-Jul-22 16:56
professionalKevin Marois11-Jul-22 16: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 12:08
professionalMycroft Holmes12-Jul-22 12:08 
GeneralRe: .Net Framework Web API & Client - Empty JSON Pin
Kevin Marois 202212-Jul-22 12:36
MemberKevin Marois 202212-Jul-22 12:36 
AnswerRe: .Net Framework Web API & Client - Empty JSON Pin
Richard Deeming12-Jul-22 21:44
mveRichard Deeming12-Jul-22 21:44 
GeneralRe: .Net Framework Web API & Client - Empty JSON Pin
Richard Deeming13-Jul-22 6:55
mveRichard Deeming13-Jul-22 6:55 
GeneralRe: .Net Framework Web API & Client - Empty JSON Pin
Kevin Marois13-Jul-22 8:14
professionalKevin Marois13-Jul-22 8:14 
QuestionVisual Studio 2022 vs Visual Studio Code for Angular development Pin
Danpeking9-Jun-22 23:20
MemberDanpeking9-Jun-22 23:20 
AnswerRe: Visual Studio 2022 vs Visual Studio Code for Angular development Pin
thatraja2-Aug-22 1:48
professionalthatraja2-Aug-22 1:48 
QuestionSearch Function Pin
Yhanzoe Adigue6-Jun-22 16:28
MemberYhanzoe Adigue6-Jun-22 16:28 
AnswerRe: Search Function Pin
Pete O'Hanlon6-Jun-22 20:41
mvaPete O'Hanlon6-Jun-22 20:41 
QuestionI'm trying to interact with a select element with selenium Pin
lucas lima 202229-May-22 13:25
Memberlucas lima 202229-May-22 13:25 
AnswerRe: I'm trying to interact with a select element with selenium Pin
behruz1230-Jul-22 19:40
Memberbehruz1230-Jul-22 19:40 
QuestionNew MVC5 project, Bootstrap update, Fail Pin
#realJSOP26-May-22 4:41
mva#realJSOP26-May-22 4:41 
AnswerRe: New MVC5 project, Bootstrap update, Fail Pin
Richard Deeming26-May-22 21:41
mveRichard Deeming26-May-22 21:41 
AnswerRe: New MVC5 project, Bootstrap update, Fail Pin
Matthew Dennis27-May-22 4:18
sysadminMatthew Dennis27-May-22 4:18 
GeneralRe: New MVC5 project, Bootstrap update, Fail Pin
#realJSOP27-May-22 10:12
mva#realJSOP27-May-22 10:12 
QuestionIMAP and SMTP Server Pin
Aashna Khanna24-May-22 21:42
professionalAashna Khanna24-May-22 21:42 
AnswerRe: IMAP and SMTP Server Pin
Richard MacCutchan24-May-22 22:01
mveRichard MacCutchan24-May-22 22:01 

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.