http-post

Posting A String Array

走远了吗. 提交于 2019-11-30 13:08:21
How can I handle an array of input For example I have in my view: <input type="text" name="listStrings[0]" /><br /> <input type="text" name="listStrings[1]" /><br /> <input type="text" name="listStrings[2]" /><br /> In my control I try to get the values like: [HttpPost] public ActionResult testMultiple(string[] listStrings) { viewModel.listStrings = listStrings; return View(viewModel); } On debugging I can see listStrings is null every time. Why is it null and how can I get the values of the input array Posting a Collection of Primitives With ASP.NET MVC To post a collection of primitives the

How to post raw body data with curl?

為{幸葍}努か 提交于 2019-11-30 11:45:47
问题 Before you post this as a duplicate; I've tried many of the suggestions I found around SO. So far I've been using postman to post data to a Java web service. That works great as follows: I now want to do the same using curl, so I tried it using the following ways: $ curl -X POST --data "this is raw data" http://78.41.xx.xx:7778/ $ curl -X POST --data-binary "this is raw data" http://78.41.xx.xx:7778/ $ curl -X POST --data "@/home/kramer65/afile.txt" http://78.41.xx.xx:7778/ $ curl -X POST -

Sending a post Request with Javascript on unload/beforeunload. Is that possible? [duplicate]

浪尽此生 提交于 2019-11-30 11:42:44
This question already has an answer here: Ajax request with JQuery on page unload 6 answers JavaScript post request like a form submit 29 answers Added: I cannot use jQuery. I am using a Siemens S7 control unit which has a tiny webserver that cannot even handle a 80kB jQuery file, so I can only use native Javascript. from this link Ajax request with JQuery on page unload I get that I need to make the request synchronous instead of asynchronous. Can that be done with native Javascript? I copied the code from here: JavaScript post request like a form submit I was wondering if I could call this

NetworkError: Failed to execute 'send' on 'XMLHttpRequest'

流过昼夜 提交于 2019-11-30 11:42:24
I'm trying to do a POST ajax request to a server hosted locally on my laptop but I can't seem to get any information back. When I click a button on my site (localhost), I can see the server passing back the correct information but on the front end I get this error: error: NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load ' http://comp-ip '. var param = JSON.stringify({varA:"varA",varB:"varB"}); $.ajax({ type: "POST", url: "http://comp-ip", async: false, data: param, success: function(result, status, xhr){ alert(result + ": " + status); }, error: function(xhr, status,

Post FromBody Always Null

空扰寡人 提交于 2019-11-30 11:03:26
I've got a new API that I'm building with ASP.NET Core, and I can't get any data POST'ed to an endpoint. Here's what the endpoint looks like: [HttpPost] [Route("StudentResults")] public async Task<IActionResult> GetStudentResults([FromBody]List<string> userSocs, [FromBody]int collegeId) { var college = await _collegeService.GetCollegeByID(collegeId); // var occupations = await _laborMarketService.GetOccupationProgramsBySocsAndCollege(userSocs, college); return Ok(); } And here's what my payload that I'm sending through Postman looks like: { "userSocs": [ "291123", "291171", "312021", "291071",

Transfer JSON to server in post request

无人久伴 提交于 2019-11-30 10:51:25
Server takes two parameters: String and JSON . Prompt, correctly I transfer JSON and String in POST request? try { HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("my_url"); List parameters = new ArrayList(2); JSONObject jsonObject = new JSONObject(); jsonObject.put("par_1", "1"); jsonObject.put("par_2", "2"); jsonObject.put("par_3", "3"); parameters.add(new BasicNameValuePair("action", "par_action")); parameters.add(new BasicNameValuePair("data", jsonObject.toString())); httpPost.setEntity(new UrlEncodedFormEntity(parameters)); HttpResponse httpResponse =

Cancel a request Alamofire

情到浓时终转凉″ 提交于 2019-11-30 10:47:24
问题 I am sending a request which is triggered based on timer. But if I press the back button the request still seems to be active and the response in turns crashes the app. Kindly suggest a way to cancel the request. Using Xcode 8.2.1 Swift 3 Here is the sample request : Alamofire.request(path!, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: createHeader()).responseJSON { response in switch response.result { case .success(let data): success(data as AnyObject?)

Android: Can not send http post

匆匆过客 提交于 2019-11-30 10:31:55
I've been banging my head trying to figure out how to send a post method in Android. This is how my code look like: public class HomeActivity extends Activity implements OnClickListener { private TextView textView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textView = (TextView) findViewById(R.id.text); Button button = (Button)findViewById(R.id.button); button.setOnClickListener(this); } @Override public void onClick(View view) { HttpPost httpMethod = new HttpPost("http://www.example.com/"); httpMethod

Android: how to do HttpPost with a certificate

最后都变了- 提交于 2019-11-30 10:21:36
I have an Application that performs an HttpPost. Now I need to add a Certificate to the post to be accepted by the server receiving the HttpPost. Please how do I go about it? Any suggestion very much appreciated !!! HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval"); try { httppost.addHeader("X-PAYPAL-SECURITY-USERID", "maurizio.pietrantuono_api1.db.com"); httppost.addHeader("X-PAYPAL-SECURITY-PASSWORD", "1395657583"); httppost.addHeader("X-PAYPAL-SECURITY-SIGNATURE", "A0GgTivJ6ivBB8QDTl

Insert data in SQL Server database from excel using HTTP Post

拈花ヽ惹草 提交于 2019-11-30 10:07:55
问题 I want to insert data into SQL Server database when I click "Insert" button in excel. The data is in Cells A2 and B2 and here is the code behind the "Insert" button in excel: Dim HttpReq As New WinHttp.WinHttpRequest HttpReq.Open "POST", "http://localhost:11121/Student/Insert/", False HttpReq.Send "jsmith112" Here is my code for the Controller action in VS: [HttpPost] public ActionResult Insert(string id) { try { student.AddToStudents(id); student.SaveChanges(); return RedirectToAction("Index