How can I correctly retrieve the request JSON payload inside this .NET controller method? [duplicate]












-2
















This question already has an answer here:




  • How to receive JSON data on WebAPI backend C#?

    4 answers



  • Receiving Json string in Web API controller

    1 answer



  • Receiving Json deserialized object as string in Web API controller

    1 answer



  • How to receive json in ASP.NET web api?

    3 answers




I have this controller method handling a POST request:



[SharePointContextWebAPIFilter]
[HttpPost]
[ActionName("InviaMailAlProtocollo")]
public IHttpActionResult InviaMailAlProtocollo(string siglaIdUor)
{

Console.WriteLine("INTO InviaMailAlProtocollo()" + siglaIdUor);

Console.WriteLine("INTO InviaAlProtocollo()" + siglaIdUor);

string requestContent = Request.Content.ToString();


return Ok("TEST");

}


I am performing a POST request passing a JSON document inside the body of the request.



How can I correctly retrieve and print this JSON document inside my controller method?










share|improve this question















marked as duplicate by CodeCaster .net
Users with the  .net badge can single-handedly close .net questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 12:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















  • so how your output will be look?

    – er-mfahhgk
    Nov 22 '18 at 11:56
















-2
















This question already has an answer here:




  • How to receive JSON data on WebAPI backend C#?

    4 answers



  • Receiving Json string in Web API controller

    1 answer



  • Receiving Json deserialized object as string in Web API controller

    1 answer



  • How to receive json in ASP.NET web api?

    3 answers




I have this controller method handling a POST request:



[SharePointContextWebAPIFilter]
[HttpPost]
[ActionName("InviaMailAlProtocollo")]
public IHttpActionResult InviaMailAlProtocollo(string siglaIdUor)
{

Console.WriteLine("INTO InviaMailAlProtocollo()" + siglaIdUor);

Console.WriteLine("INTO InviaAlProtocollo()" + siglaIdUor);

string requestContent = Request.Content.ToString();


return Ok("TEST");

}


I am performing a POST request passing a JSON document inside the body of the request.



How can I correctly retrieve and print this JSON document inside my controller method?










share|improve this question















marked as duplicate by CodeCaster .net
Users with the  .net badge can single-handedly close .net questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 12:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















  • so how your output will be look?

    – er-mfahhgk
    Nov 22 '18 at 11:56














-2












-2








-2









This question already has an answer here:




  • How to receive JSON data on WebAPI backend C#?

    4 answers



  • Receiving Json string in Web API controller

    1 answer



  • Receiving Json deserialized object as string in Web API controller

    1 answer



  • How to receive json in ASP.NET web api?

    3 answers




I have this controller method handling a POST request:



[SharePointContextWebAPIFilter]
[HttpPost]
[ActionName("InviaMailAlProtocollo")]
public IHttpActionResult InviaMailAlProtocollo(string siglaIdUor)
{

Console.WriteLine("INTO InviaMailAlProtocollo()" + siglaIdUor);

Console.WriteLine("INTO InviaAlProtocollo()" + siglaIdUor);

string requestContent = Request.Content.ToString();


return Ok("TEST");

}


I am performing a POST request passing a JSON document inside the body of the request.



How can I correctly retrieve and print this JSON document inside my controller method?










share|improve this question

















This question already has an answer here:




  • How to receive JSON data on WebAPI backend C#?

    4 answers



  • Receiving Json string in Web API controller

    1 answer



  • Receiving Json deserialized object as string in Web API controller

    1 answer



  • How to receive json in ASP.NET web api?

    3 answers




I have this controller method handling a POST request:



[SharePointContextWebAPIFilter]
[HttpPost]
[ActionName("InviaMailAlProtocollo")]
public IHttpActionResult InviaMailAlProtocollo(string siglaIdUor)
{

Console.WriteLine("INTO InviaMailAlProtocollo()" + siglaIdUor);

Console.WriteLine("INTO InviaAlProtocollo()" + siglaIdUor);

string requestContent = Request.Content.ToString();


return Ok("TEST");

}


I am performing a POST request passing a JSON document inside the body of the request.



How can I correctly retrieve and print this JSON document inside my controller method?





This question already has an answer here:




  • How to receive JSON data on WebAPI backend C#?

    4 answers



  • Receiving Json string in Web API controller

    1 answer



  • Receiving Json deserialized object as string in Web API controller

    1 answer



  • How to receive json in ASP.NET web api?

    3 answers








c# .net asp.net-mvc asp.net-apicontroller






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 12:07









CodeCaster

107k17142193




107k17142193










asked Nov 22 '18 at 11:51









AndreaNobiliAndreaNobili

13k54181326




13k54181326




marked as duplicate by CodeCaster .net
Users with the  .net badge can single-handedly close .net questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 12:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by CodeCaster .net
Users with the  .net badge can single-handedly close .net questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 12:08


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • so how your output will be look?

    – er-mfahhgk
    Nov 22 '18 at 11:56



















  • so how your output will be look?

    – er-mfahhgk
    Nov 22 '18 at 11:56

















so how your output will be look?

– er-mfahhgk
Nov 22 '18 at 11:56





so how your output will be look?

– er-mfahhgk
Nov 22 '18 at 11:56












1 Answer
1






active

oldest

votes


















1














First To need To Declare A Data transfer object(DTO) Details Here
In your model Folder that looks the same as the json object.



Forexmaple you have a json object looks like this:



{
Id:22,
Name:"Ibrahim",
Children:["Name1","Name2","Name3"]
}



make a corresponding plain old Csharp object(Poco)
like the following:



  public class ParentBasicInfo
{
public int Id {get ;set;}
public string Name{get ;set;}
public List<string>Children{get ;set;}
}


in your controller put an instance of your poco:



Replace:



public IHttpActionResult InviaMailAlProtocollo(string siglaIdUor)
{
}


with :



public IHttpActionResult InviaMailAlProtocollo(ParentBasicInfo siglaIdUor)
{
}


all of the json object will be inslide of siglaIdUor



you can access its properties like any object.



Hope that Helps.






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    First To need To Declare A Data transfer object(DTO) Details Here
    In your model Folder that looks the same as the json object.



    Forexmaple you have a json object looks like this:



    {
    Id:22,
    Name:"Ibrahim",
    Children:["Name1","Name2","Name3"]
    }



    make a corresponding plain old Csharp object(Poco)
    like the following:



      public class ParentBasicInfo
    {
    public int Id {get ;set;}
    public string Name{get ;set;}
    public List<string>Children{get ;set;}
    }


    in your controller put an instance of your poco:



    Replace:



    public IHttpActionResult InviaMailAlProtocollo(string siglaIdUor)
    {
    }


    with :



    public IHttpActionResult InviaMailAlProtocollo(ParentBasicInfo siglaIdUor)
    {
    }


    all of the json object will be inslide of siglaIdUor



    you can access its properties like any object.



    Hope that Helps.






    share|improve this answer




























      1














      First To need To Declare A Data transfer object(DTO) Details Here
      In your model Folder that looks the same as the json object.



      Forexmaple you have a json object looks like this:



      {
      Id:22,
      Name:"Ibrahim",
      Children:["Name1","Name2","Name3"]
      }



      make a corresponding plain old Csharp object(Poco)
      like the following:



        public class ParentBasicInfo
      {
      public int Id {get ;set;}
      public string Name{get ;set;}
      public List<string>Children{get ;set;}
      }


      in your controller put an instance of your poco:



      Replace:



      public IHttpActionResult InviaMailAlProtocollo(string siglaIdUor)
      {
      }


      with :



      public IHttpActionResult InviaMailAlProtocollo(ParentBasicInfo siglaIdUor)
      {
      }


      all of the json object will be inslide of siglaIdUor



      you can access its properties like any object.



      Hope that Helps.






      share|improve this answer


























        1












        1








        1







        First To need To Declare A Data transfer object(DTO) Details Here
        In your model Folder that looks the same as the json object.



        Forexmaple you have a json object looks like this:



        {
        Id:22,
        Name:"Ibrahim",
        Children:["Name1","Name2","Name3"]
        }



        make a corresponding plain old Csharp object(Poco)
        like the following:



          public class ParentBasicInfo
        {
        public int Id {get ;set;}
        public string Name{get ;set;}
        public List<string>Children{get ;set;}
        }


        in your controller put an instance of your poco:



        Replace:



        public IHttpActionResult InviaMailAlProtocollo(string siglaIdUor)
        {
        }


        with :



        public IHttpActionResult InviaMailAlProtocollo(ParentBasicInfo siglaIdUor)
        {
        }


        all of the json object will be inslide of siglaIdUor



        you can access its properties like any object.



        Hope that Helps.






        share|improve this answer













        First To need To Declare A Data transfer object(DTO) Details Here
        In your model Folder that looks the same as the json object.



        Forexmaple you have a json object looks like this:



        {
        Id:22,
        Name:"Ibrahim",
        Children:["Name1","Name2","Name3"]
        }



        make a corresponding plain old Csharp object(Poco)
        like the following:



          public class ParentBasicInfo
        {
        public int Id {get ;set;}
        public string Name{get ;set;}
        public List<string>Children{get ;set;}
        }


        in your controller put an instance of your poco:



        Replace:



        public IHttpActionResult InviaMailAlProtocollo(string siglaIdUor)
        {
        }


        with :



        public IHttpActionResult InviaMailAlProtocollo(ParentBasicInfo siglaIdUor)
        {
        }


        all of the json object will be inslide of siglaIdUor



        you can access its properties like any object.



        Hope that Helps.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 12:01







        user9786715






















            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python