How can I correctly retrieve the request JSON payload inside this .NET controller method? [duplicate]
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?
c# .net asp.net-mvc asp.net-apicontroller
marked as duplicate by CodeCaster
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.
add a comment |
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?
c# .net asp.net-mvc asp.net-apicontroller
marked as duplicate by CodeCaster
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
add a comment |
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?
c# .net asp.net-mvc asp.net-apicontroller
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
c# .net asp.net-mvc asp.net-apicontroller
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
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
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 22 '18 at 12:01
user9786715
add a comment |
add a comment |
so how your output will be look?
– er-mfahhgk
Nov 22 '18 at 11:56