Click here to Skip to main content
15,907,687 members
Home / Discussions / Web Development
   

Web Development

 
QuestionDraw 3*3 Rubik’s cube Pin
Member 1449931913-Jun-19 6:53
Member 1449931913-Jun-19 6:53 
AnswerRe: Draw 3*3 Rubik’s cube Pin
#realJSOP13-Jun-19 7:48
professional#realJSOP13-Jun-19 7:48 
AnswerRe: Draw 3*3 Rubik’s cube Pin
ZurdoDev17-Jun-19 11:33
professionalZurdoDev17-Jun-19 11:33 
QuestionProblems Calling Asp.Net WebAPI 2 Pin
Kevin Marois11-Jun-19 12:07
professionalKevin Marois11-Jun-19 12:07 
AnswerRe: Problems Calling Asp.Net WebAPI 2 Pin
Richard Deeming12-Jun-19 0:45
mveRichard Deeming12-Jun-19 0:45 
GeneralRe: Problems Calling Asp.Net WebAPI 2 Pin
Kevin Marois12-Jun-19 4:02
professionalKevin Marois12-Jun-19 4:02 
GeneralRe: Problems Calling Asp.Net WebAPI 2 Pin
Richard Deeming12-Jun-19 4:25
mveRichard Deeming12-Jun-19 4:25 
GeneralRe: Problems Calling Asp.Net WebAPI 2 Pin
Kevin Marois12-Jun-19 5:26
professionalKevin Marois12-Jun-19 5:26 
Well I just created a quick console app.

Controller
I created a wrapper entity that contains the params I'm passing. Both the 'Trigger' param and the list of results are now properties on the AssayResultsEntity class. No other changes here.
[HttpPost]
public Response<List<string>> ExecuteRuleGroup(AssayResultsEntity results)
{
    var response = new Response<List<string>>();

    try
    {
        IRulesBL bl = GetBL();
        response.Data = bl.ExecuteRuleGroup(results.Trigger, results.Results);
    }
    catch (Exception e)
    {
        response.Exception = e;
    }

    return response;
}
Console App
This works fine.
class Program
{
    private readonly static string uri = "http://localhost:65078/API";
    private readonly static HttpClient client = new HttpClient();
    static void Main(string[] args)
    {
        RunAsync().GetAwaiter().GetResult();
    }
    static async Task RunAsync()
    {
        client.BaseAddress = new Uri("http://localhost:65078/");
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        try
        {
            await SendRulesAsync();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
        Console.ReadLine();
    }
    static async Task SendRulesAsync()
    {
        // Sample data
        AssayResultsEntity asr = new AssayResultsEntity
        {
            Trigger = "rule_trigger_bay_run_complete",

            Results = new List<AssayResultEntity>
            {
                new AssayResultEntity { AccessionNumber = "Test 1" },
                new AssayResultEntity { AccessionNumber = "Test 2" },
                new AssayResultEntity { AccessionNumber = "Test 3" },
            }
        };
        HttpResponseMessage response = await client.PostAsJsonAsync("api/Rules/ExecuteRuleGroup", asr);
        response.EnsureSuccessStatusCode();
        var returnValue = await response.Content.ReadAsAsync<Response<List<string>>>();
    }
}

So this leads me to believe that my WebAPIExecutor class is the culprit. Anything wrong with this above approach? Again, I pretty new to WebAPI's so I'm not always sure.

one question.. .the PostAsJsonAsync methos only takes 1 param. Is it possible to pass multiple params to the controller using this?

Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

GeneralRe: Problems Calling Asp.Net WebAPI 2 Pin
Kevin Marois12-Jun-19 6:34
professionalKevin Marois12-Jun-19 6:34 
GeneralRe: Problems Calling Asp.Net WebAPI 2 Pin
Richard Deeming12-Jun-19 8:10
mveRichard Deeming12-Jun-19 8:10 
QuestionEliminating External (Commercial) References/Creating my own design/Stylesheets Pin
Member 120802018-Jun-19 6:23
Member 120802018-Jun-19 6:23 
AnswerRe: Eliminating External (Commercial) References/Creating my own design/Stylesheets Pin
Afzaal Ahmad Zeeshan8-Jun-19 10:18
professionalAfzaal Ahmad Zeeshan8-Jun-19 10:18 
AnswerRe: Eliminating External (Commercial) References/Creating my own design/Stylesheets Pin
jamieereynoldss9-Jun-19 23:51
jamieereynoldss9-Jun-19 23:51 
AnswerRe: Eliminating External (Commercial) References/Creating my own design/Stylesheets Pin
#realJSOP10-Jun-19 5:08
professional#realJSOP10-Jun-19 5:08 
QuestionHow to learn python numpy library easily, which functions are important Pin
Member 144829305-Jun-19 22:54
Member 144829305-Jun-19 22:54 
AnswerRe: How to learn python numpy library easily, which functions are important Pin
User 41802546-Jun-19 3:56
User 41802546-Jun-19 3:56 
SuggestionRe: How to learn python numpy library easily, which functions are important Pin
Richard Deeming6-Jun-19 4:38
mveRichard Deeming6-Jun-19 4:38 
GeneralRe: How to learn python numpy library easily, which functions are important Pin
User 41802546-Jun-19 6:05
User 41802546-Jun-19 6:05 
QuestionPass Guid To Controller Pin
Kevin Marois4-Jun-19 8:37
professionalKevin Marois4-Jun-19 8:37 
AnswerRe: Pass Guid To Controller Pin
Richard Deeming5-Jun-19 12:26
mveRichard Deeming5-Jun-19 12:26 
GeneralRe: Pass Guid To Controller Pin
Kevin Marois7-Jun-19 8:03
professionalKevin Marois7-Jun-19 8:03 
GeneralRe: Pass Guid To Controller Pin
Kevin Marois11-Jun-19 12:08
professionalKevin Marois11-Jun-19 12:08 
QuestionConfused about App secrets Pin
Super Lloyd30-May-19 19:32
Super Lloyd30-May-19 19:32 
AnswerRe: Confused about App secrets Pin
Kornfeld Eliyahu Peter2-Jun-19 22:44
professionalKornfeld Eliyahu Peter2-Jun-19 22:44 
AnswerRe: Confused about App secrets Pin
Eddy Vluggen2-Jun-19 23:04
professionalEddy Vluggen2-Jun-19 23:04 

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.