I’m using the « GET » method in a synchronus way but I have noticed that the responseXML is empty even the readyState value is equal to 4
Which means the response is delivered form the server side
Anyone have an idea ? why the response is empty
Many thanks in advance
Because target document returns nothing, maybe? Look !
//sandbox.phpcode.eu/g/empty.php
Maybe the MIME-type of the result isn't
text/xml
or
application/xml
for some reason.
Related
I'm trying to get a web page using vb.net and HtmlAgilityPack with this code:
Dim mWPage As New HtmlAgilityPack.HtmlDocument
Dim wC As New WebClient()
mWPage.Load(wC.OpenRead(mUrl))
My problem is to get text from a table but, when I extract InnerText, i get something like this:
Modificat<!--span-->i dati
instead of (Note that I wrote the same string and below it's displayed correctly):
Modificati dati
I've tryed to use the answer here but it doesn't work in this case (or I wasn't able to make it works)
I noticed that contents changes when I change "User-Agent", so I tryed various "User-Agent" but I never got a perfect text.
So my questions are:
can I use the code that is indicated in the answer to solve the problem?
if not, can I get a perfect text using the right "User-Agent"?
If so, how can I find the right "User-Agent"?
If not, how can I fix the receivedstring?
The response from the server based on a new User-Agent is fully dependent on the server so we will not be able to predict which one will yield the response you're looking for.
But... You will be able to use the HttpUtility.HtmlDecode method to get rid of the encoded HTML and turn it into teh string you're looking for.
To filter out the HTML comment you may need to change the XPath you're using. If you append //text(), you should get only the text elements that match the rest of your expression.
Did anyone know why I'm always getting an empty response for the mayorship of a venue? Say I perform a request like this
https://api.foursquare.com/v2/venues/51a2445e5019c80b56934c75
I don't get the actual mayor of this place. However, according to this https://developer.foursquare.com/docs/api/venues/details it should be in the venues response.
Ok I got it. You have to add the param for swarm-style response. So the actual request should look like this:
https://api.foursquare.com/v2/venues/51a2445e5019c80b56934c75?m=swarm
What is the correct response on a GET request for multiple objects where one or more of them does not exist? e.g.:
http://domain.net/event-list/?ids=1&ids=5&ids=3
where object with id 5 does not exist. Should I return a list with just objects 1 and 3 or should I return some kind of error? What is the correct response?
Also I wonder If the behaviour should be any different if the request is POST. For instance:
$.post('domain.net/events/bulk-edit/?ids=1&ids=5&ids=3', { public: true });
Should I just perform operation for the objects that exist or do not perform operation at all and return an error?
I know there are some debates if non-empty querystrings are ok for POST requests. I think they are alright just for this particular case where you request a subset of objects to do something with them.
Okay, I gave it some thoughts and here is what I believe were the right thing to do.
This is a bit of a headache since you're requesting multiple objects at once which is usually a WebDAV-thing, bringing wonders such as the 207/Multistatus response with it. Let me start of with saying that I think your query string has the wrong format. I think it really should look like this:
?ids[]=1&ids[]=5&ids[]=3
Now about responses on a GET request. I believe the following response codes were the right ones:
200 if any object could be found by id
400 on a missing or empty ids query parameter (unless you think no ids should translate into get all objects)
404 if none of the given ids match any object
If you want to notify the client that the request couldn't be satisfied in parts, you are free to send a Warning header along (cf RFC 2616, sec 14.46). However, if you really want to do it absolutely right™, here's how to deal with requests where not every id is valid:
If all ids could be used to load an object, send the 200/Ok response code
If there are any ids that could not be used to load an object, redirect via 301/Moved Permanently to a new URL sans the offending ids param(s)
As for the POST request: It is my understanding that you'd like to set multiple events as public in one go? If so, I'd really change the order: Send a POST to http://domain.net/events/publish and send the ids in the post body.
I m trying to change the fulfilment status of an order , this is the json
data sent :
{"fulfillment":{"tracking_number":null,"line_items":[{"id":"XXXXXXX"}]}} and this is the url "/admin/orders/XXXXXXXXX/fulfillments.json"
but i get this error "Unprocessable entity" .
looking for your help .
thanks
Alaeddine
What was the body of the response?
"Unprocessable entity" is a 422 HTTP response, which is generally used for validation errors. Validation errors will generally have a description of the error in the body of the response which might help debug the problem.
Edit: As David Underwood mentioned:
The ID you need to provide is for the line item, not the variant. When you fetch the order you'll see the ids of the line items in the response. Those are the ones you need when creating the fulfillment.
This usually happens if the order and/or line item has already been fulfilled. Another common issue is not setting the accept and content type headers for your request.
If that isn't the case and the other suggestions done help could you post the order I'd so we can look into what is happening in your specific case?
I've inherited a site that uses a less then ideal way to handle images, they have been stored in the DB as BLOBs. The image tags consist of
<img src='image.php?id=22' />
but no images are displaying. When I visit the image.php?id=22 page, the BLOB data is just dumped out on to the screen (all funny characters) and no image is shown. I'm not sure if this has to do with the content type of data that's being sent to the browser? I've been told "this used to work fine until a few weeks ago".
My question is, is it even possible to display BLOB data as the src attribute of an image tag?
EDIT: by request, here are the contents of image.php. Hope this is of some use.
<?
error_reporting(0);
include("../inc/connect.inc");
include("../inc/common.inc");
include("item.class");
$item = new Item($id);
echo $item->Picture;
?>
EDIT2: If i add the content-type line, the page just prints out the path to the image: http://www.site.com/dir/image.php?id=49. Tried with several content types, no difference. Strange!
You should have, in the database, a content-type field as well as the BLOB data, unless the BLOB data is one fixed type (e.g., image/png) where you can hardcode it in your image.php script. You'll need to include a new header with the Content-type: set.
header('Content-type: image/png');
But you'll have to find out what the image type is - trial and error will do I guess, it's gotta be one of image/jpeg, image/png or image/gif surely?
Well, if you linked directly to the image the exact same data would be sent back, there's no distinction between a 'BLOB' and just data read by the webserver and sent to the browser.
So, you're on the right track with the content-type idea... What does firebug say the content-type is? You might want to post the code for image.php.
edit:
So there we go... Just modify your script to look like:
<?
header( 'Content-Type: image/png' );
error_reporting(0);
include("../inc/connect.inc");
include("../inc/common.inc");
include("item.class");
$item = new Item($id);
echo $item->Picture;
?>
Replacing image/png with whatever format your images are.