http-post

Getting a POST endpoint to work in self-hosted (WebServiceHost) C# webservice?

左心房为你撑大大i 提交于 2019-11-27 05:23:15
So, I have been messing around with webservices for a while now, and I keep getting back to some basics, that I never seem to get right. Question 1: When using a WebServiceHost in .NET/C#, you can define a method/endpoint as using GET/POST/etc. Setting up a GET-method is easy and it works pretty much directly, and its easy to understand how it works. For example: [OperationContract] [WebInvoke(Method = "GET", UriTemplate = "/PutMessage/{jsonString}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] string PutMessage(string

Having troubles calling a Controller Post Method

陌路散爱 提交于 2019-11-27 05:23:07
Here's my method [AcceptVerbs(HttpVerbs.Post)] public void SaveImage(FormCollection formValues) { byte[] contents = Convert.FromBase64String(Request.Form["file"]); System.IO.File.WriteAllBytes(Server.MapPath(Request.Form["name"]), contents); } It is getting posted to from this actionscript method: public function encodeAndSave(e:MouseEvent = null):void { var date:Date = new Date(); var by:ByteArray = PNGEnc.encode(canvas.main_bdata); var req:URLRequest = new URLRequest(server_path+"Home/SaveImage"); var params:URLVariables = new URLVariables(); params.file = Base64.encodeByteArray(by); params

http post blackberry (null response)

泄露秘密 提交于 2019-11-27 04:54:24
问题 I have used this code mod from some url here : HttpConnection httpConnection = (HttpConnection) Connector.open(webservice_address,Connector.READ_WRITE); httpConnection.setRequestMethod(HttpConnection.POST); httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); URLEncodedPostData encPostData = new URLEncodedPostData("UTF-8", false); encPostData.append("category", String.valueOf(category)); byte[] postData = encPostData.toString().getBytes("UTF-8");

Sending Files using HTTP POST in c# [closed]

只愿长相守 提交于 2019-11-27 04:30:30
I have a small C# web application.How can I get the c# code that allows user to send files by HTTP POST.It should be able to send text files,image files,excel, csv, doc (all types of files) without using stream reader and all. You can try the following code: public void PostMultipleFiles(string url, string[] files) { string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x"); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary; httpWebRequest.Method = "POST"; httpWebRequest

Read associative array from json in $_POST

你。 提交于 2019-11-27 04:21:08
问题 I am using jQuery to post a json object to my php application. jQuery.post("save.php",JSON.stringify(dataToSend), function(data){ alert(data); }); The json string as pulled from firebug looks like this { "data" : [ { "contents" : "This is some content", "selector" : "DIV.subhead" }, { "contents" : "some other content", "selector" : "LI:nth-child(1) A" } ], "page" : "about_us.php" } In php I am trying to turn this into an associative array. My php code so far is <?php $value = json_decode

How to handle Ajax JQUERY POST request with WCF self-host

隐身守侯 提交于 2019-11-27 04:16:24
There are many reasons create a RESTful WCF server (it is easy) and even better if you can avoid ASP and it's security box (if all you are doing is simple requests to return information). See: http://msdn.microsoft.com/en-us/library/ms750530.aspx on how to do this. What I found is that handling AJAX (JQUERY) GET requests is easy. But dealing with JSON in a POST is tricky. Here is an example of a simple GET request contract: [OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Json)] String Version(); And the implementaion is here (which returns a JSON) public partial class

Java httpPost into .asp form

拈花ヽ惹草 提交于 2019-11-27 04:09:01
问题 In Java, if I want to send data to form on the server, where form type is: <form method="post" id="form1" name="form1" action=""> <div id="login" class="box"> <div class="header">Log in</div> <div class="content"> <label for="txtUser">User:</label> <input id="txtUser" name="txtUser" type="text" size="13" value="" /> <label for="txtPassword">Password:</label> <input id="txtPassword" name="txtPassword" type="password" size="13" value="" /> <input id="BLogin" name="BLogin" type="submit" value=

Getting a POST variable

扶醉桌前 提交于 2019-11-27 03:55:35
I am using C# with ASP.NET. How do I check if a parameter has been received as a POST variable? I need to do different actions if the parameter has been sent via POST or via GET. Use this for GET values: Request.QueryString["key"] And this for POST values Request.Form["key"] Also, this will work if you don't care whether it comes from GET or POST, or the HttpContext.Items collection: Request["key"] Another thing to note (if you need it) is you can check the type of request by using: Request.RequestType Which will be the verb used to access the page (usually GET or POST). Request.IsPostBack

How to receive json data using HTTP POST request in Django 1.6?

£可爱£侵袭症+ 提交于 2019-11-27 02:58:09
I am learning Django 1.6. I want to post some JSON using HTTP POST request and I am using Django for this task for learning. I tried to use request.POST['data'] , request.raw_post_data , request.body but none are working for me. my views.py is import json from django.http import StreamingHttpResponse def main_page(request): if request.method=='POST': received_json_data=json.loads(request.POST['data']) #received_json_data=json.loads(request.body) return StreamingHttpResponse('it was post request: '+str(received_json_data)) return StreamingHttpResponse('it was GET request') I am posting JSON

How to use getJSON, sending data with post method?

眉间皱痕 提交于 2019-11-27 02:55:16
I am using above method & it works well with one parameter in URL. e.g. Students/getstud/1 where controller/action/parameter format is applied. Now I have an action in Students controller that accepts two parameters and return a JSON object. So how do I post data with $.getJSON() using post method? Similar methods are also acceptable. The point is to call an action of the controller with AJAX. The $.getJSON() method does an HTTP GET and not POST. You need to use $.post() $.post(url, dataToBeSent, function(data, textStatus) { //data contains the JSON object //textStatus contains the status: