frombodyattribute

Why is the HttpWebRequest body val null after “crossing the Rubicon”?

余生颓废 提交于 2019-12-25 02:49:14
问题 I am trying to send the contents of an XML file from a handheld device (Compact Framework/Windows CE) to a Web API method in my server app like so (Client code): public static string SendXMLFile(string xmlFilepath, string uri, int timeout) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.KeepAlive = false; request.ProtocolVersion = HttpVersion.Version10; request.Method = "POST"; StringBuilder sb = new StringBuilder(); using (StreamReader sr = new StreamReader

FromBody value get null

大兔子大兔子 提交于 2019-12-21 01:18:46
问题 This is Asp.Net Webform application This is my POST method in my Apicontroller public void Post([FromBody]string value) { } I'm with fiddler post process. I did so experiment. But it did not. What is the problem. Can you help? I've tried it, I've failed. public void Post(MyViewModel model) { string aa = model.Value; } public class MyViewModel { public string Value { get; set; } } In Fiddler: Request Body: Value=hakan 回答1: The POST body payload in Fiddler should be: =foo_bar instead of: value

C# Web API POST parameter FromBody is always null

被刻印的时光 ゝ 提交于 2019-12-13 14:31:47
问题 I've been scouring the web for hours and tried many different solutions also described here on StackOverflow. I know similar questions have been asked before, but none of the answers or comments have worked for me. The problem: I have a .NET Web API that has a Post-method with some parameters. One of the parameters is a complex object that is supposed to be read from the body (that is JSON). However, this object is always null . This is my code: // POST api/worksheets/post_event/true/false

Should I use “[FromBody]” values or custom params when responding to an HTTP Post call in a Web API app?

Deadly 提交于 2019-12-11 12:16:36
问题 Is POST the right HTTP method/verb to use for telling the server which criteria to use to retrieve data and then save it locally? I want to send an URL from a client (Windows Forms) app/util to my Web API app to tell it to retrieve data via a Stored Proc, then store the results in a local table. No data is returned to the caller, it's just a notification to do some work. To prepare for this, I added a new route to WebApiConfig: // Some reports (monthly) only need a begindate, such as "201509"

How can I pass a bunch of XML to a RESTful method from Android without putting it into the URL?

笑着哭i 提交于 2019-12-11 05:17:14
问题 I know how to do this in C#, in fact I wrote a tip about it here, but I don't know how to accomplish it in Java/Android. My code is this so far: protected void doInBackground(String... params) { String URLToCall = "http://10.0.2.2:28642/api/DeliveryItems/PostArgsAndXMLFileAsStr"; String result = ""; String stringifiedXML = params[0]; HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(URLToCall); List<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add

How can I pass a moderately large volume of data to my Web API app?

无人久伴 提交于 2019-12-07 15:00:20
问题 I've got this code in a Web API Controller: [Route("{unit}/{begindate}/{enddate}")] [HttpPost] public void Post(string unit, string begindate, string enddate, [FromBody] string stringifiedjsondata) { List<ProduceUsageSPResults> _produceUsageList = JsonConvert.DeserializeObject<List<ProduceUsageSPResults>>(stringifiedjsondata); string _unit = unit; string _begindate = String.Format("{0}01", HyphenizeYYYYMM(begindate)); string _enddate = GetEndOfMonthFor(enddate); string appDataFolder =

How can I pass a moderately large volume of data to my Web API app?

♀尐吖头ヾ 提交于 2019-12-05 20:55:19
I've got this code in a Web API Controller: [Route("{unit}/{begindate}/{enddate}")] [HttpPost] public void Post(string unit, string begindate, string enddate, [FromBody] string stringifiedjsondata) { List<ProduceUsageSPResults> _produceUsageList = JsonConvert.DeserializeObject<List<ProduceUsageSPResults>>(stringifiedjsondata); string _unit = unit; string _begindate = String.Format("{0}01", HyphenizeYYYYMM(begindate)); string _enddate = GetEndOfMonthFor(enddate); string appDataFolder = HttpContext.Current.Server.MapPath("~/App_Data/"); string htmlStr = ConvertProduceUsageListToHtml(

How to pass DataTable via FromBody to Web API POST method (C#)

给你一囗甜甜゛ 提交于 2019-12-04 05:39:43
问题 I am successfully calling a POST method in a Web API app from a Winforms client that passes some parameters for a Stored Procedure. I would prefer, though, to pass the results of the Stored Procedure (which I have to run on the client first) to the POST method via the FromBody functionality, if possible. It's a lot of data to send over the wire, but the way I'm doing it now I have to run the SP twice - first on the client Winforms app, then on the Web API server app, and the simultaneous

FromBody value get null

狂风中的少年 提交于 2019-12-03 06:53:18
This is Asp.Net Webform application This is my POST method in my Apicontroller public void Post([FromBody]string value) { } I'm with fiddler post process. I did so experiment. But it did not. What is the problem. Can you help? I've tried it, I've failed. public void Post(MyViewModel model) { string aa = model.Value; } public class MyViewModel { public string Value { get; set; } } In Fiddler: Request Body: Value=hakan The POST body payload in Fiddler should be: =foo_bar instead of: value=foo_bar That's just one of those strange things about the model binding in the Web API. If you want to

REST API: GET request with body

匆匆过客 提交于 2019-11-28 13:16:47
I want to implement a REST API and need a body on my GET requests. (Like discussed here: HTTP GET with request body ) Are there http clients which are not able to send a body with a GET request? Fiddler is able to do it, although the message box is red. As a general rule, the idea of a GET in REST is that any of your parameters are sent in the URL. As the answer on the question you included indicates, it's doable but misses the point of REST, which is to have a consistent webbish interface. If you want to pass complex data to your endpoint, you probably want to use a POST, which your users