w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Python GAE Requests not returning cookies after get request
I tried urlfetch it seems to be showing the cookie headers: import logging from google.appengine.api import urlfetch response = urlfetch.fetch(url) logging.info(response.headers)

Categories : Python

Bad Request (400) error while trying to access REST API using requests in python
auth argument is to set Authorization header (basic http authentication by default). The API expects credentials in the body: r = request.post(url, data=xml, headers={'Content-Type': 'application/xml'}) where xml=b"<authCommand><userID>sdm@company.com</authCommand>...".

Categories : Python

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

Uploading multiple files in a single request using python requests module
Multiple files with different key values can be uploaded by adding multiple dictionary entries: files = {'file1': open('report.xls', 'rb'), 'file2': open('otherthing.txt', 'rb')} r = requests.post('http://httpbin.org/post', files=files)

Categories : Misc

Google translate API (Paid Api) Request Error for few requests randomly while sending multiple request in Asp.net
Increase quota of Google Translator API by increasing characters/second/user Limit. https://code.google.com/apis/console/#project:149xxxxxxx84:quotas

Categories : C#

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

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

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

Angular.js canceling $http requests inside bind() event
it indeed was because it's inside the nonangular bind() event, putting scope.$apply() after http and before resolve will fix it https://github.com/angular/angular.js/issues/1159#issuecomment-20368490 el.bind('keyup', function() { var canceler = $q.defer(); $http.post('/api', data, {timeout: canceler.promise}).success(success); scope.$apply(); canceler.resolve(); });

Categories : Javascript

How do i bind data source to a ComboBox?
If you have set the display member like: ModelComboBox.DataSource = bindingSource3; ModelComboBox.DisplayMember = "ColumnName"; And it still shows funny values, what are the values that it shows exactly? Note, in a toolstrip it looks like you may have to also do: ModelComboBox.BindingContext = this.BindingContext; here is a reference

Categories : C#

How can I bind multiple datagrids source using MVVM?
Assuming that you have a collection of Shelf called Shelves on your ViewModel, you can use an ItemsControl, or a ListBox if you need selection, and define a DataTemplate: <ItemsControl ItemsSource="{Binding Path=Shelves}"> <ItemsControl.ItemTemplate> <DataTemplate> <DataGrid ItemsSource="{Binding Path=Products}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>

Categories : C#

How to Bind the Image Source according the selected item?
With the information you have provided i would do it as follows <Button Name="btn"> <Button.Header> <StackPanel> <Image name="img" Source="{Binding SelectedItem.Image, ElementName=myListBox}" /> <StackPanel> </Button.Header> </Button> <ListBox x:Name="myListBox"> </ListBox>

Categories : Wpf

How to bind CheckBoxes from GridView to source DataTable?
Here is how you can go about it, first assign an id to your checkboxes cbx.ID = "cbxDoTest. Then add a RowCommand event handler that will be triggered when your Validate tests button is clicked. Here you need to traverse the e.Row.Cells properties, if the cell belonged to a test column then do a search on the checkbox control (Checkbox cbx = e.Row.Cell[i].FindControl("cbxDoTest"); then check if the cbx.Checked is true or false. I wrote the flow and how to do it from my head so double check the method/property names.

Categories : C#

How do I bind to one data source but update trigger from another?
If I understand you correctly, there is a much easier way to achieve what you want: <ListBox ItemsSource={Binding Items} /> <TextBox Text="{Binding Items/PropertyName}" /> Assuming that your ObservableCollection has a bindable property named PropertyName in it and that your view model (or DataContext) has a property called Items of the type of your ObservableCollection, then the TextBox control will display the PropertyName value of the currently selected item in the collection. You can find out more about the '/' path syntax from the PropertyPath XAML Syntax page on MSDN.

Categories : C#

How can I bind an image source based on its name (string)?
In constructor of this newsObject class add switch(Type) block, and there apply different images according of Type value (I assume that in this class you have image or path_to_image atribute)

Categories : C#

trying to bind datagrid item source to a property in another class
Let's say your Dialog control is named DialogControl and has a DependencyProperty named Items defined in its code behind. In the XAML, I would bind this property to the DataGrid like this: <DataGrid ItemsSource="{Binding Items, RelativeSource={RelativeSource Mode= FindAncestor, AncestorType={x:Type DialogControl}}" /> This RelativeSource binding will go off and search through the properties of your DialogControl class and find the Items property. Note: Do NOT set the DataContext of the UserControl to itself. Now in your MainWindow.xaml.cs file where you instantiate your DialogControl, you can set the Items property: DialogControl dialogControl = new DialogControl(); dialogControl.Items = someCollection; dialogControl.Show(); UPDATE >>> Oh I see what you're after now... you wa

Categories : Wpf

MonoTouch.Dialog Unable To Bind source property
The key part of the warning here seems to be on null-object By default, MvvmCross Views find their ViewModels during ViewDidLoad() - so a solution to you current problem might be to call base.ViewDidLoad(): public override void ViewDidLoad() { base.ViewDidLoad(); // the rest of your Load code }

Categories : IOS

Bind the new data source without re-initializing kendo grid which was already initialized
This is what is working for me. I can't say that it's the best solution. I initialize the gird on first load only then I set the DataSouce on subsequent changes to the grid. In this example my assignmentFitlers object contains 38 different optional parameters that define which contacts to view. My grid reload each time the filters change. I think this could work for you. function bindGrid(e) { var assignmentFilters = e.assignmentFilters; var gridDataSource = new kendo.data.DataSource({ transport: { read: { url: '@Url.Action("Read", "GridModule")', type: 'POST', contentType: 'application/json' }, parameterMap: function (options) {

Categories : Jquery

Optimize a SQL request containing sub requests on the same table
You could clean up the first 2 with this, not entirely sure about the third part, it's unclear what you're after, how can the score be greater than the max score from the same table? SELECT MAX(score) AS bestScore , MAX(CASE WHEN player_id = {$l_playerId}) THEN score ELSE '' END) AS playerScore FROM `{$l_tableName}`

Categories : Mysql

1 request vs 2 requests to web service from iphone
The first step is to design a web service API. That may sound simple, but the opposite is the case. The "client" never makes such decisions, rather it "adapts". Once the web service API is set in stone, you try your best to implement the corresponding client API on iOS. So, your task at the end of the day would possibly be to send a POST request whose content is JSON: { "member_id": 1234567, "event_id": 7654321 } What that JSON contains is defined by the web service API. Don't bother what the web service is doing with it - just give it what it requires.

Categories : Iphone

making many ajax requests instead of one request
You should see two requests : one for $.ajax() one for load() The most likely cause of multiple requests is that the delegated click handler is attached multiple times. It needs to be attached once, not once per row. You may be able to reduce the two requests to one as follows : var $pard_admin = $("#pard_admin").on("click", ".deleteArticle", function(event) { event.preventDefault(); var $row = $(this).closest('tr'); $.ajax({ url: "../pard_site/view/delete.php", type: "POST", data: { "deleteId": $row.find('td:first').text() }, success: function() { $row.remove();//or similar, depending on exactly what should disappear from the interface on successful delete. } }); });

Categories : Jquery

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

Additional requests for images after jQuery ajax request
the task is simple: to load one div from another site and append it to a current website. This is problem number 1. You cannot load content from a 3rd party domain. This is a security feature of all browsers known as the Same Origin Policy.

Categories : Jquery

Does PHP Validate Requests Against a WSDL Prior to Sending the Request?
It looks like your question is : You are trying to make a SOAP call though PHP on server side and you don't know if the call is made. If you want to check whether or not the call was made , you may replace the SOAP object with a mock object of yours and within the mock object try to see f the call is made.

Categories : PHP

Asynchronous request multiple URLs, and most requests are timed out
Not exactly an answer, but if you have .net 4.5 and VS2012 you can use async await, which is much cleaner. The code would be... var tasks = from url in URLs let request = WebRequest.Create(url) select request.GetRequestStreamAsync(); Stream[] results = Task.WaitAll(tasks); However this isn't a very good way to write code. You should process your streams as quickly as possible, as Windows should limit the number of Http streams your program can have open at the same time.

Categories : C#

Servicestack RegistrationFeature Unable to bind request
Happened to me also. Turned out it was the swagger that was not passing the integer because i had space inside my variable: [ApiMember(Name = " TrackingItemId", ...... (notice space before the variable!)

Categories : C#

Only bind part of the Form mappings from request
Since you want to keep the value, that probably means a hidden input when you rerender the form. If the previous value comes from elsewhere, e.g. the database, you could define another form with an ignored mapping for that field.

Categories : Scala

How to convert http Web Request to asynchronous requests using aysnc and await
The absolute easiest way is to replace HttpWebRequest with HttpClient. You'll also want to use an asynchronous method signature: public static async Task<string> LogInAsync(string email, string password)

Categories : C#

Sending one AJAX request, but receiving multiple requests on the controller side
You have multiple rows but assign only one unique ID to bind to? Look in to using classes instead of IDs. IDs should be unique (only one "delete" on the entire page, not one per row). Chances are your biding is getting confused and firing twice because the IDs aren't unique. Also, I'm coming to this conclusion because your binding is $('#delete').click(...) and you only reference id in your AJAX call and not iterate over a collection of ids. Otherwise, a checkbox--per-line would have some form of iterator and multiple AJAX calls (or at the very least bundle the DELETE request so it's sending multiple IDs). Having said that, try something like (excuse my creative liberty on the element structure and how I've stored the IDs): <div class="people"> <div class="person" data-id="1

Categories : Jquery

Google Services OAuth requests returns HTTP 400 Bad Request Error
For anyone experiencing this issue, I've basically come to the conclusion that google hasn't interfaced calendar with their service accounts yet, and am using a refresh token to achieve similar results without having to log in all the time.

Categories : PHP

CORS POST Requests not working - OPTIONS (Bad Request) - The origin is not allowed
Ok I got past this. This has got to be the strangest issue I've ever encountered. Here's how to "solve" it: Continue on with life as usual until suddenly out of no where OPTIONS requests to this domain begin returning 200 OK (instead of 400 Bad Request) and POST never happens (or at least seems like it doesn't because the browser swallows it) Realize that Fiddler's OPTIONS response mysteriously contains duplicates for "Access-Control-Allow-XXX". Try removing the following statement from you web.config even though you clearly remember trying that to fix the previous issue and it not working: Remove this: <httpProtocol> <customHeaders> <remove name="X-Powered-By" /> <add name="Access-Control-Allow-Origin" value="http://mydomain.com" /&

Categories : Asp Net

JMeter: How to send HTTP requests with different request body for each thread count?
You will have to parametrized your test plan and use CSV data set config to use the data from csv file. I have created a beginners screen cast to explain how to use csv data set config . As you mentioned you cannot reuse the same data, you will have to either create a big enough csv to match or your concurrent user needs, or use once only controller to not replay those request again, which will create duplicate users.

Categories : Http

Avoiding POST requests resulting in "400 - Bad Request" status code in Spring MVC
I think the best way to handle this is to add a 'required' parameter into RequestParam annotation. @RequestParam(value="name", required=false) http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/bind/annotation/RequestParam.html

Categories : Spring

Requests library crashing on Python 2 and Python 3 with
This means that the server did not send an encoding for the content in the headers, and the chardet library was also not able to determine an encoding for the contents. You in fact deliberately test for the lack of encoding; why try to get decoded text if no encoding is available? You can try to leave the decoding up to the BeautifulSoup parser: if response.encoding is None: soup = bs4.BeautifulSoup(response.content) and there is no need to pass in the encoding to BeautifulSoup, since if .text does not fail, you are using Unicode and BeautifulSoup will ignore the encoding parameter anyway: else: soup = bs4.BeautifulSoup(response.text)

Categories : Python

What is the source of packet size in a GET request?
First of all, the discrepancy you are observing is probably due either to different host headers or to the passing of cookies between client and server, although referrer could be another source of variation. A given GET packet is of the following format. In the case of the below example, the packet size is 361 bytes. GET / HTTP/1.1 Host: google.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729) Accept: */* Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive The first line is determined by the URL; however, all subsequent lines are headers. Headers are passed by the client to communicate detail

Categories : Http

Golang http request results in EOF errors when making multiple requests successively
I'm going to guess there is no problem with your code. The most likely cause of your problem is because the server is closing the connection. Rate limiting is one possible reason for this. Your test shouldn't be relying on an external service that's very brittle and not hermetic. Instead you should think about spinning up a test server locally.

Categories : Go

How do you Identify the request that a QNetworkReply finished signal is emitted in response to when you are doing multiple requests In QtNetwork?
I am not familiar to PyQt but from general Qt programming point of view Using only one QNetworkAccessManager is right design choice finished signal provides QNetworkReply*, with that we can identify corresponding request using request(). I hope this will solve your problem with one manager and multiple requests. This is a C++ example doing the same.

Categories : Qt

Two DataTables in one Page source Ajax request
You're creating a datatable on the DIV of id grid_estoque instead of the TABLE of id lista_estoque. And datatable can only be created on an html TABLE. Thus, replace oTableEstoque = $('#grid_estoque').dataTable({ by oTableEstoque = $('#lista_estoque').dataTable({

Categories : Jquery

Grabbing redirect request source in WordPress or PHP
That would be the referer (and it's not very reliable): $_SERVER['HTTP_REFERER']; Wordpress has it's own version: wp_get_referer() that accesses $_REQUEST['_wp_http_referer']) internally

Categories : PHP

How to split a string of Python source code into Python "statements"?
I'm not familiar with the internals of the Python lexer (though almost certainly many people on SO are :), but my guess is that you're basically looking for lines, with one important exception : paired open-close delimiters that can span multiple lines. As a quick and dirty first pass, you might be able to start with something that splits a piece of code on newlines, and then you could merge successive lines that are found to contain paired delimiters -- parentheses (), braces {}, brackets [], and quotes '', ''' ''' are the ones that come to mind.

Categories : Python



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