w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
trying to post file to php server using python and requests
When you pass a dictionary to the data parameter of requests.post, it will be form-encoded. I'm not totally familiar with the Java code, but it looks like it is actually using an encoded String as the data of the request. In order to achieve the same thing with requests, pass a string as the data parameter, like so: data = 'filedata=foo&filename=bar&systemid=&fooe&createNew=false' r = requests.post(url, files=files, headers=headers, data=data) See a similar example in the documentation here.

Categories : PHP

Print a formatted POST request URL using Python requests
You can add the following to print out debug info about all your requests: import logging logging.basicConfig(level=logging.DEBUG) You'll get output like INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): <URL> DEBUG:requests.packages.urllib3.connectionpool:"POST /oauth/token HTTP/1.1" 200 None If you want to print other information, you can print out the objects you're passing in or implement some of the requests event hooks.

Categories : Python

Python Requests - Post a zip file with multipart/form-data
As far as requests is concerned, there is no difference between a zip file and any other binary blob of data. Your server is broken here; it is cutting of the connection when you send it a zip file. That is not something requests can do anything about. You may want to test against http://httpbin.org/ when you run into problems like these; it is a testing service built by the author of the requests library. Another tip: you don't need to read the whole file object into memory when sending. Just pass the object itself to requests instead: fileobj = open('/Users/.../test.zip', 'rb') r = requests.post(url, auth=HTTPDigestAuth('dev', 'dev'), data = {"mysubmit":"Go"}, files={"archive": ("test.zip", fileobj)}) Demo against httpbin.org: >>> import requests >>> fileobj = op

Categories : Python

multipart data POST using python requests: no multipart boundary was found
You should NEVER set that header yourself. We set the header properly with the boundary. If you set that header, we won't and your server won't know what boundary to expect (since it is added to the header). Remove your custom Content-Type header and you'll be fine.

Categories : Python

Two $.post requests one after the other.Second $.post request doesn't get executed
$.post() is an abbreviated form of the $.ajax() structure. I usually prefer to use the $.ajax() structure because: It's easier to see if I've missed anything I can more easily add additional params, such as asynch: false, When new to ajax I found it considerably easier to troubleshoot this structure In your case, you might find your problem easier to solve in a $.ajax() structure, since it would be easier to see that a second ajax call (that depends on the outcome of a first ajax call) must happen in the success function of the first ajax call. Here is a standalone example (too bad jsFiddle cannot handle ajax...): TESTER.PHP <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="

Categories : Ajax

python-requests returning unicode Exception message (or how to set requests locale)
You can try os.strerror, but it would probably return nothing or the same non-English string. This hard-coded English was scraped from here: http://support.microsoft.com/kb/819124 ENGLISH_WINDOWS_SOCKET_MESSAGES = { 10004: "Interrupted function call.", 10013: "Permission denied.", 10014: "Bad address.", 10022: "Invalid argument.", 10024: "Too many open files.", 10035: "Resource temporarily unavailable.", 10036: "Operation now in progress.", 10037: "Operation already in progress.", 10038: "Socket operation on nonsocket.", 10039: "Destination address required.", 10040: "Message too long.", 10041: "Protocol wrong type for socket.", 10042: "Bad protocol option.", 10043: "Protocol not supported.", 10044: "Socket type not supported.",

Categories : Python

How to limit download rate of HTTP requests in requests python library?
There are several approaches to rate limiting; one of them is token bucket, for which you can find a recipe here and another one here. Usually you would want to do throttling or rate limiting on socket.send() and socket.recv(). You could play with socket-throttle and see if it does what you need. This is not to be confused with x-ratelimit rate limiting response headers, which are related to a number of requests rather than a download / transfer rate.

Categories : Python

how to create POST data in django python
You should NEVER modify POST data. What you can do instead, as a work around is: post_dict = request.POST.copy() Now you have access to request.POST as a local dictionary. You can update the dictionary as: post_dict.update('loginfailed', False) Now, use this post_dict as a context variable sent into the template where you can do {% if post_dict.login_failed %} Or even simpler. Just send {'login_failed': False} in the context, so you can access it as {% if login_failed %} {# do this #} {% else %} {# do that #} {% endif %}

Categories : Python

Consecutive requests with python Requests.Session() not working
In the lastest version of requests, he sessions object is with Cookie Persistence, look the requests Sessions ojbects docs. So you don't need add the cookie artificialy. Just import requests s=requests.Session() login_data = dict(userName='user', password='pwd') ra=s.post('http://example/checklogin.php', data=login_data) print ra.content print ra.headers ans = dict(answer='5') r=s.post('http://example/level1.php',data=ans) print r.content Just print the cookie to look up wheather you were logged. for cookie in s.cookies: print (cookie.name, cookie.value) And is the example site is yours? If not maybe the site reject the bot/crawler ! And you can change your requests's user-agent as looks likes you are using a browser. For example: import requests s=requests.Session() headers

Categories : Python

Caching in JAX-RS for POST requests
HTTP has methods that are safe or unsafe, and methods that are idempotent or not idempotet. See the HTTP spec: Methods can also have the property of "idempotence" in that (aside from error or expiration issues) the side-effects of N > 0 identical requests is the same as for a single request. The methods GET, HEAD, PUT and DELETE share this property. You can GET, PUT, or DELETE a Resources as often as you like, the result will be the same, no matter how often you do it. As you see, POST is not idempotet. It makes a difference to POST a request to a Resource once, twice, or more often. That's because the semantics of POST is to create something below the Resource you POST to. Because of all this, it makes no sense to cache the result of a POST request.

Categories : Rest

POST Requests from a Servlet
Your localhost has your localhost IP as a sending IP. Openshift et al has the Openshift et al IP as a sending IP. So the Google API says "I have only seen that localhost IP twice before, that's fine!", whereas it says "I have seen this Openshift IP millions of times before! NO REPLY FOR YOU!"

Categories : Java

How to block IPs for POST requests, but not GET?
Change the order of allow deny like this: <Limit POST PUT DELETE> order allow,deny allow from all deny from 210.5.214.128/29 deny from 210.89.69.160/28 # Hundreds more lines... # My current IP (sample provided here, actual used in reality), to test deny from 100.100.100.100 </Limit> <Limit GET HEAD> order deny,allow allow from all </Limit>

Categories : Apache

Handling Post Requests
There are a number of suitable ways to handle this, and the decision is largely a matter of preference and what you're familiar with. Spring can handle this sort of job quite well. Note: Maven is a build system for Java and some other JVM languages. I recommend using it, but it's not part of Spring; what you're probably looking for is Spring MVC.

Categories : Java

How to run JMeter with different post requests
To do this, use: CSV Data Set, this will export as variables the columns in each row of your CSV Then you just use variables this way ${var1} in Http Request sampler

Categories : Http

SSL Proxy/Charles and Android trouble
See here: http://jaanus.com/blog/2012/02/12/debugging-http-on-an-android-phone-or-tablet-with-charles-proxy-for-fun-and-profit/ You would need to install the charles.crt certificate to your device.

Categories : Android

Require.js timeout with Charles proxy
Turns out the issue was related to hosts file. Requirejs was throwing timeout because localhost was taking too long to resolve. Everything works fine after updating hosts file to this: ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost.localdomain 127.0.0.1 localhost 127.0.0.1 username.lmuk.local 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost More information available here.

Categories : Javascript

Why JSF POST requests don't work with PrettyFaces
First of all, thanks for helping. It is something strange, that's why I couldn't isolate the problem (to get it happen in another project), which is not executing the POST requests at first try, but from the second one. I have removed the filters I had in web.xml without any difference. The same behavior. I've just had the idea of testing the project in other Tomee version than 1.5.2. Surprisingly, dev version 1.6.0 from 29.07.2013 seems to don't have this problem. Why didn't I think at this sooner? :( I had to write separate Servlet components for my post functionalities. Aaaah! Well, this means that not PrettyFaces was problematic (Huraay!), but, probably, Apache MyFaces, CDI impl. or something else in Tomee. Uf...I'm so happy that it works now. Thanks again for trying to help. ////

Categories : JSF

Same Rails 4 routes for GET and POST requests
You can use match as long as you have via: match "user/account" => "user#account", as: :user_account, via: [:get, :post] Edit: Added a as: parameter so that it will be accessible via a url helper. user_account_path or user_account_url in this case.

Categories : Ruby

Laravel 4 CSRF on all POST requests
In my BaseController I have this: public function __construct() { $this->beforeFilter('csrf', array('on' => array('post', 'delete', 'put'))); $this->beforeFilter('ajax', array('on' => array('delete', 'put'))); } Having such App::before filter is an interesting approach but I don't know which is better?

Categories : PHP

IOS http POST requests seem to be empty
Try this function in server side function getRealPOST() { $result = array(); $b = explode("&", urldecode(file_get_contents("php://input"))); foreach($b as $k => $v) { list($ind, $val) = explode("=", $v); $result[$ind] = $val; } return $result; } $post = getRealPOST() echo "<pre>"; print_r($post); hope it will help to get post data in other way not using $_POST

Categories : PHP

How to GET and POST requests separately with HttpRequestHandler
The HttpServletRequest provides the method getMethod() Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.

Categories : Java

Spring 4.x/3.x (Web MVC) REST API and JSON2 Post requests, how to get it right once for all?
CURL Post call curl -i -H "Content-Type: application/json" -X POST -d '{"id":100,"username":"JohnBlog","name":"John","lastName":"Blog","email":"JohnBlog@user.com"}' http://localhost:8080/[YOURWEBAPP]/api/user/add Different Error Scenarios: Here I explore different errors you might come across after you have made a curl call and what might have possibly gone wrong. Scenario One: HTTP/1.1 404 Not Found Server: Apache-Coyote/1.1 Content-Type: text/html;charset=utf-8 Content-Length: 949 Date: Tue, 04 Jun 2013 02:59:35 GMT This implies that the REST API does not exist in the URL you have provide. Root cause: You might have a typo in your request (believe me this can happen)! It could be that your spring configuration is not right. If this is the case it needs further digging into wha

Categories : Java

Enabling CORS with WebAPI PUT / POST requests?
POST, PUT, DELETE, etc use pre-flighted CORS. The browser sends an OPTIONS request. Since you do not have an action method that handles OPTIONS, you are getting a 405. In its most simplest form, you must implement an action method like this in your controller. public HttpResponseMessage Options() { var response = new HttpResponseMessage(); response.StatusCode = HttpStatusCode.OK; return response; } One thing to note is that the customHeaders you have configured in web.config will already be adding the necessary Access-Control-Allow-Origin and Access-Control-Allow-Methods headers. So the action method is not doing the same. Implementing action method in controller works but may not be a good option. A better option will be to implement a message handler that does this for yo

Categories : Asp Net Web Api

How to use POST request in PHP with FullContactAPI for Batch Requests?
can you try removing the single quotes from the request array. "requests" => ["https://api.fullcontact.com/v2/person.json?email=bart@fullcontact.com","htps://api.fullcontact.com/v2/person.json?email=jigarbhatt30893@yahoo.co.in"]

Categories : PHP

Mechanical Turk rejects POST Requests
You can't POST XML to Mechanical Turk over REST. It looks like you're confusing REST with SOAP to me. Mechanical Turk's REST interface only takes URL-encoded key-value pairs, like this: https://mechanicalturk.amazonaws.com/?Service=AWSMechanicalTurkRequester &AWSAccessKeyId=[the Requester's Access Key ID] &Version=2012-03-25 &Operation=CreateHIT &Signature=[signature for this request] &Timestamp=[your system's local time] &HITTypeId=T100CN9P324W00EXAMPLE &Question=[URL-encoded question data] &LifetimeInSeconds=604800

Categories : Java

WCF Data Service with WIF 4.5; Principal not set for POST requests
Problem solved, this is the correct configuration to ensure batch requests work correctly with WIF 4.5 using a WCF Data Service <behavior> <serviceCredentials useIdentityConfiguration="true" /> <serviceAuthorization principalPermissionMode="Always" impersonateOnSerializingReply="true" /> </behavior>

Categories : Wcf

How can I set $.ajaxStart() and $.ajaxStop() to fire only on POST requests?
i guess you could do something like this: jQuery.ajaxPrefilter(function( options) { if(options.type !== 'POST') { options.global = false; } }); See:: jQuery prefilters

Categories : Javascript

How to handle both GET and POST requests in TornadoWeb framework?
Ok.If you want to handle them together, try this class MainHandler(tornado.web.RequestHandler): def get(self): self.post() def post(self): self.render('intro.html')

Categories : Python

how to listen to post requests from foursquare push api
No, all you need to do is send requests and receive responses. Please take a look at this -> python-requests.org -> The documentation provided how you can send and receive requests. So, for example, you could send a POST request like so: r = requests.get('https://api.github.com/user', <your arguments here>) And now r would contain the POST response from the said url.

Categories : Python

Java servlet- Best way to get post requests body
Use request.getInputStream() to get the body as an InputStream, and parse this stream with an XML parser.

Categories : Java

PHP not parsing x-www-form-urlencoded data during non-POST requests
I ran into a similar problem when building a RESTful API. The following is code which builds $requestData. To Orestes' point, I don't modify superglobals. Should get you started: switch ($request_method) { case 'get': $requestData = $_GET; break; case 'post': $requestData = $_POST; break; case 'put': case 'delete': // read string from PHP's special input location and parse into an array parse_str(file_get_contents('php://input'), $requestData); break; }

Categories : PHP

java send GET/POST requests while maintaining cookies
HttpClient automatically handles cookies as long as you use the same DefaultHttpClient object.

Categories : Java

PUT and DELETE requests unsuccessful on PHP REST API, but POST and GET are fine
From the Slim Framework Documentation: Unfortunately, modern browsers do not provide native support for HTTP PUT requests. To work around this limitation, ensure your HTML form’s method attribute is “post”, then add a method override parameter to your HTML form like this: <form action="/books/1" method="post"> ... other form fields here... <input type="hidden" name="_METHOD" value="PUT"/> <input type="submit" value="Update Book"/> </form> If you are using Backbone.js or a command-line HTTP client, you may also override the HTTP method by using the X-HTTP-Method-Override header. You can use any request type you would like (including custom ones like foo), but GET and POST are the only ones natively supported by moder

Categories : PHP

Why would large POST requests not reach my Azure web role?
I'm totally sure that there's something blocking the request to reach IIS. Probably Firewall rules or Load Balancer, that's why you could not see the logs in IIS. The bad news, is that I could not find a way to tell that you'll post large content. Try to apply this configs to the "ServiceDefinition.csdef" file and see if it will help in something: <?xml version="1.0" encoding="utf-8"?> <ServiceDefinition name="WindowsAzure1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-03.2.0"> <LoadBalancerProbes> <LoadBalancerProbe protocol="http" name="config" timeoutInSeconds="36000"></LoadBalancerProbe> </LoadBalancerProbes> <WebRole name="webRoleConfig"> <Runtime executionContext="elevat

Categories : Iis

How do I make real POST requests in an E2E beforeEach() function?
The e2e testing environment doesn't have access to either jQuery or Angular functions by default. I would add jQuery to the testing environment. You can do this by following lorcan's answer (not currently the top answer) to this question: How to execute jQuery from Angular e2e test scope? Once you have jQuery available, you can do a standard ajax request: beforeEach(function() { $.ajax({ url:"/your/function/here", async:false, success: function(data) { alert(data); }}); }); Make sure you set async to be false. You'll probably want to do something different with the success function, like assigning the return data to a variable.

Categories : Angularjs

How Can I save post requests to mongoengine using django forms?
If you use mongoengine>=0.8 then: blog = Blog.from_json('''{ "text": "My first blog post", "tags": [ {"tag":"mongo"}, {"tag":"django"} ] }''').save() or if you already have dict: blog = Blog._from_son({ "text": "My first blog post", "tags": [ {"tag":"mongo"}, {"tag":"django"} ] }).save()

Categories : Django

Is it possible to work with Dropbox REST API without any libraries, using only GET&POST requests?
Yes, but Dropbox OAuth steps require signing in via the HTML representation. Source. Note: This is the only step that requires an endpoint on www.dropbox.com. All other API requests are done via api.dropbox.com or api-content.dropbox.com. After the OAuth process, you will receive the token and the secret. With these, you can make calls to the REST API using HTTP requests. Here is an SO question and a nice answer discussing the Dropbox authentication with JavaScript (though using a library) :Transfer files to dropbox from node js without browser based oauth authentication

Categories : Android

Timeout issue for long requests on ajax POST
It looks like on your local network to external azure site, you are going out through a proxy/gateway server. Does your company have any block-lists or white-lists for allowed/disallowed websites that might be intercepting and blocking the request?

Categories : Asp Net Mvc

differentiating between different post requests on the same page in Django views.py
Submit buttons in HTML have name and value properties. For example if you have: <form> <input type="submit" name="action" value="Send"/> <input type="submit" name="action" value="Hello"/> </form> Then in Django you can distinguish the two submit actions by the value of action: if request.POST['action'] == 'Send': # do this elif request.POST['action'] == 'Hello': # do that

Categories : Python

How do I configure a Ruby Mechanize agent to work through the Charles web proxy?
A web proxy is not normally defined by just a port, but is usually a full host name. Charles is very likely installed on localhost. Therefore the following adjustment may work for you: @agent ||= Mechanize.new do |agent| agent.set_proxy("localhost", 8888) end

Categories : Ruby



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.