http-post

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

时光怂恿深爱的人放手 提交于 2019-12-03 08:31:40
问题 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

How do I add basic authentication to a Python REST request?

徘徊边缘 提交于 2019-12-03 08:05:37
I have the following simple Python code that makes a simple post request to a REST service - params= { "param1" : param1, "param2" : param2, "param3" : param3 } xmlResults = urllib.urlopen(MY_APP_PATH, urllib.urlencode(params)).read() results = MyResponseParser.parse(xmlResults) The problem is that the url used to call the REST service will now require basic authentication (username and password). How can I incorporate a username and password / basic authentication into this code, as simply as possible? If basic authentication = HTTP authentication, use this: import urllib import urllib2

AFNetworking- post request- add simple text to body

☆樱花仙子☆ 提交于 2019-12-03 07:09:44
How do i add a simple string (no JSON or any other format), to a post request using AFNetworking? The best i've already succeeded was concat with '='. And this: NSURLRequest* request =[myServer multipartFormRequestWithMethod:@"POST" path:@"http://my.server.com" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { NSData *tmp_data = [NSString stringWithFormat:@"%@", @"my_string!"]; [formData appendPartWithHeaders:nil body:tmp_data]; }]; Thanks in advance! As simple as is, This should be the answer: NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

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

JSON vs Form POST

帅比萌擦擦* 提交于 2019-12-03 06:30:37
问题 We're having a bit of a discussion on the subject of posting data to a REST endpoint. Since the objects are quite complex, the easiest solution is to simply serialize them as JSON and send this in the request body. Now the question is this: Is this kosher? Or should the JSON be set as a form parameter like data=[JSON]? Or is sending of JSON in the request body just frowned upon for forcing the clients using the application, to send their data via JavaScript instead of letting the browser

Android Multipart HTTP Post does not send the File's MIME type

旧城冷巷雨未停 提交于 2019-12-03 06:17:35
Trying to figure what's wrong with my codings. I followed a blog post from here . I managed to get the codes to actually upload the file to a PHP web service. However, for some reason although I've set explicitly the MIME type for the file, PHP shows that the MIME is just a blank string and therefore rejected. Here's my codings: public String SendPost(String fn, String bid, String caption, String uid, String APIKey, String postHash) throws ParseException, ClientProtocolException, IOException { HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter

SOAP object over HTTP post in C# .NET

穿精又带淫゛_ 提交于 2019-12-03 05:47:43
I am trying to compose a SOAP message(including header) in C# .NET to send to a URL using HTTP post. The URL I want to send it to is not a web-service, it just receives SOAP messages to eventually extract information from it. Any ideas on how to do this? First you need to create a valid XML. I use Linq to XML to achieve this, like follow: XNamespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/"; var document = new XDocument( new XDeclaration("1.0", "utf-8", String.Empty), new XElement(soapenv + "Envelope", new XAttribute(XNamespace.Xmlns + "soapenv", soapenv), new XElement(soapenv +

How to POST URL in data of a curl request

非 Y 不嫁゛ 提交于 2019-12-03 05:32:13
问题 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. 回答1: Perhaps you don't have to include the single quotes: curl --request POST 'http://localhost/Service' --data "path=/xyz/pqr/test/&fileName=1.doc"

How do I print the content of httprequest request?

放肆的年华 提交于 2019-12-03 04:46:17
问题 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

Android set content type HttpPost

二次信任 提交于 2019-12-03 04:41:00
How can you change the content-type of a HttpPost in android? For a request I need to set the content type to application/x-www-form-urlencoded So i got this bit of code: httpclient=new DefaultHttpClient(); httppost= new HttpPost(url); StringEntity se = new StringEntity(""); se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded")); httppost.setEntity(se); But that doesn't do the trick and I cant find the solution anywhere. Cheers HttpPost httppost = new HttpPost(builder.getUrl()); httppost.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded