http-post

StringContent Vs FormUrlEncodedContent

穿精又带淫゛_ 提交于 2019-12-02 23:24:22
I have a URL I want to post a body with parameters to such in the form of data="blahblahblah". However, my "blahblahblah" in this case is a full fledged XML, I simple it down to something like below: <Parent id="1"> <Child id="1"/> </Parent> I can get this to work find with HTTPClient FormUrlEncodedContent find with the following approach. var values = new List<KeyValuePair<string, string>>(); values.Add(new KeyValuePair<string, string>("data", XMLBody)); var content = new FormUrlEncodedContent(values); HttpResponseMessage sResponse = await sClient.PostAsync(action.URL, content).ConfigureAwait

Escaping parameters in set_form_data POST

南楼画角 提交于 2019-12-02 23:22:33
问题 This is the oddest thing. When I add the ; in set_form_data , value gets interpreted as value; on the server side. When I remove the ; , the value for 'dontescape' gets interpreted as file%3a%2f%2f%2fpath%2fto . What the heck is happening? I don't want anything escaped unless I explicitly call CGI::escape! Please help :) postParams = { 'key1' => 'value', 'dontescape' => 'file:///path/to' } url = URI.parse('https://my.url') req = Net::HTTP::Post.new(url.path) req.basic_auth('username',

The type or namespace name 'HttpGet' could not be found when add 'System.Web.Http' namespace

无人久伴 提交于 2019-12-02 22:19:00
I have one issue in MVC . Currently I am working in MVC and the version is MVC4 . And I have 2 ActionResult Method, see below [HttpGet] public ActionResult About() { ViewBag.Message = "Your app description page."; return View(); } [HttpPost] public ActionResult About(ModelName ccc) { ViewBag.Message = "Your app description page."; return View(); } We need the using System.Web.Mvc; namespace for [HttpPost] and [HttpGet] attributes. So I added the using System.Web.Mvc; namespace in my controller . But i need to add another one Namespace using System.Web.Http; for httpsresponseexpection error

Host is unresolved in LAN

白昼怎懂夜的黑 提交于 2019-12-02 19:24:10
问题 Im getting a IOExeption 'Host is unresolved' on HttpPost. The Endpoint in this case a a computer on my LAN with a webservice. (http://pc259:8080/test/service.asmx). Im using WIFI to my LAN. Does Android know to to resolved computernames? StringEntity se = new StringEntity(xmlDataToSend); se.setContentType("text/xml"); HttpPost httppost = new HttpPost(endPoint); httppost.setHeader("Content-Type","application/soap+xml"); httppost.setEntity(se); HttpClient httpclient = new DefaultHttpClient();

Django returns 403 error when sending a POST request

一笑奈何 提交于 2019-12-02 18:27:29
when I'm using following Python code to send a POST request to my Django website I'm getting 403: Forbidden error. url = 'http://www.sub.domain.com/' values = { 'var': 'test' } try: data = urllib.urlencode(values, doseq=True) req = urllib2.Request(url, data) response = urllib2.urlopen(req) the_page = response.read() except: the_page = sys.exc_info() raise When I'm opening any other website it works properly. domain.com is Django website too, and it works properly too. I think, that's Django config problem, can anyone tell me what should I do to provide access to my script? Does the view that

S3 - Anonymous Upload - Key prefix

与世无争的帅哥 提交于 2019-12-02 18:19:35
I am trying to understand exactly how to setup a bucket that is generally private but allows anonymous uploads with restrictions. The specific criteria are: The bucket is mostly private and requires my key/secret to add/remove/update/list files. There is a "directory" (i.e. key prefix) called "incoming" that will allow anonymous users to upload content to but not list. The bucket has a one day expiration on all content. As a bonus I would like the "incoming" directory to have a 30 minute expiration although if that is not possible a one day expiration for the whole bucket will do. Files with

How do I print the content of httprequest request?

北城余情 提交于 2019-12-02 17:57:59
I've got a bug involving httprequest, which happens sometimes, so I'd like to log HttpGet and HttpPost request's content when that happens. So, let's say, I create HttpGet like this: HttpGet g = new HttpGet(); g.setURI(new URI("http://www.google.com")); g.setHeader("test", "hell yeah"); This is the string representation that I'd like to get: GET / HTTP/1.1 Host: www.google.com test: hell yeah With the post request, I'd also like to get the content string. What is the easiest way to do it in java for android? Juned Ahsan You can print the request type using: request.getMethod(); You can print

How to POST URL in data of a curl request

孤者浪人 提交于 2019-12-02 17:54:21
I am trying to post two parameters using curl , path and fileName : curl --request POST 'http://localhost/Service' --data "path='/xyz/pqr/test/'&fileName='1.doc'" I know something is wrong in this. I have to use something like URLEncode. I tried many things still no luck. Please give an example how can I post the url in data of curl request. Perhaps you don't have to include the single quotes: curl --request POST 'http://localhost/Service' --data "path=/xyz/pqr/test/&fileName=1.doc" Update: Reading curl's manual, you could actually separate both fields with two --data: curl --request POST

Posting data to server and response is :{“Message”:“An error has occurred.”}

倾然丶 夕夏残阳落幕 提交于 2019-12-02 17:38:48
问题 I have tried many methods of posting data to server but none of them worked and only response am getting is: {"Message":"An error has occurred."} Below is the method I've tried recently. NSString *cust_id=@"2"; NSString *Prod_ID=@"18"; NSString *Vend_ID=@"1"; NSString *Quant=@"2"; NSString *post =[NSString stringWithFormat:@"customerid=%@&productid=%@&vendorid=%@&quantity=%@",cust_id,Prod_ID,Vend_ID,Quant]; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion

How to post to a request using node.js

泪湿孤枕 提交于 2019-12-02 15:49:24
I am trying to post some json to a URL. I saw various other questions about this on stackoverflow but none of them seemed to be clear or work. This is how far I got, I modified the example on the api docs: var http = require('http'); var google = http.createClient(80, 'server'); var request = google.request('POST', '/get_stuff', {'host': 'sever', 'content-type': 'application/json'}); request.write(JSON.stringify(some_json),encoding='utf8'); //possibly need to escape as well? request.end(); request.on('response', function (response) { console.log('STATUS: ' + response.statusCode); console.log(