Bing Maps Query API, query by address instead of lat/long doesn't seem to work - bing-api

Based on this documentation, I should be able to construct the query url with an address string inside the spatialFilter paramater. It works when I pass in the longitude/latitude, but I need to be able to pass in an address, a zip code, a city, or a state. An end user will be making a query for nearby locations of this custom datasource, they won't be searching geo-coordinates in the search box. Whenever I pass in a string other than lat/long, I receive a 400 BadRequest response: "Latitude values must be between -90.0 and 90.0 degrees."
Here is what my request url looks like:
https://spatial.virtualearth.net/REST/v1/data/myId/myDataSource/myEntity?spatialFilter=nearby(ADDRESS_STRING,1000)&$format=json&$top=10&key=myKey&jsonp=callback

Make sure that you have single quotes on either side of your address string. For example:
http://spatial.virtualearth.net/REST/v1/data/20181f26d9e94c81acdf9496133d4f23/FourthCoffeeSample/FourthCoffeeShops?spatialFilter=nearby('Paris',100)&key=YOUR_BING_MAPS_KEY
If your address has a single quote in it, then you have to escape it the OData way which consists of putting two single quotes together. For example "o''clock"

Related

How to intercept a specific URL with wildcards

I have an app, two different URLs are fetched. Part of the URL is a hash which needs wildcard pattern, and I want to capture just one URL in an intercept.
But the similarity of the string makes it difficult to get a pattern that works.
/api/v1/payment/duedate?type=payment&cache_buster=...
/api/v1/payment/6309503a5c058a702224?cache_buster=... // capture this one
I tried
cy.intercept('/api/v1/payment/*?cache_buster')
It seems I need to negate specific parts of pathname or query params, but it does not seem possible to do so.
You can indeed negate a section of the URL, but not in the query parameter parts.
This will select any URL with /payment/* but exclude the one with /payment/duedate.
cy.intercept('/api/v1/payment/!(duedate*)')
You could also try a regex, or use javascript code in a routeHandler callback.

I am trying to get list of estimates from zoho books to zoho creator but its giving me error of data type mismatch

Please check this image for more details and code its simple code but i am getting datatype mismatch error
https://i.stack.imgur.com/rDYH6.png
This is the common format to get list of records in zoho books module.
<variable> = zoho.books.getRecords(<module_name>, <org_ID>, <search>, <connection>);
module_name: Name of the module
org_id: Your organization id
search: specifies the values based on which the records will be filtered. You can specify an empty string or an empty map for this param, in which case all the records will be fetched
connection: Name of the connection
In order to get list of estimates Please do the following,
response = zoho.books.getRecords("Estimates", "54654632", "", "zbooks");
For further clarification refer this document https://www.zoho.com/deluge/help/books/fetch-records.html
If you have any other queries reach out to us at support#zohobooks.com
You are using single quotes for strings which Deluge intercepts as date or date-time strings. Use double quotes instead.
The error shown on the screenshot is caused by the single quote you're using instead of double quotes (").
You can use as following:
data = zoho.books.getRecords("Estimmates","OrganizationID","Connection");

Find Place requests Returns Only One Result

I'm using the Google Places API endpoint "findplacefromtext" and tried a search similar to the example.
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=mongolian%20grill&inputtype=textquery&fields=photos,formatted_address,name,opening_hours,rating&locationbias=circle:2000#47.6918452,-122.2226413&key=YOUR_API_KEY
However, when you use this it only ever returns one result. There is a cafe near me that's called "Cream" but when you pass that as the "input" parameter it returns shops that have a category of "Ice Cream". I thought it should only search the name of the business.... If I can't find the place by name does it search the category type as a fall back? When I execute the same search in Google Maps it returns the same data but I get multiple results and I can see the place I am trying to retrieve 3rd on the search result list.
Is it possible to make it return more than one result? The documentation doesn't mention anything about this.
I believe what you need is the Text Search request. The Find Place request is meant for exact addresses.
The Google Places API Text Search Service is a web service that
returns information about a set of places based on a string — for
example "pizza in New York" or "shoe stores near Ottawa" or "123 Main
Street". The service responds with a list of places matching the text
string and any location bias that has been set.
The service is especially useful for making ambiguous address queries
in an automated system, and non-address components of the string may
match businesses as well as addresses. Examples of ambiguous address
queries are incomplete addresses, poorly formatted addresses, or a
request that includes non-address components such as business names.
Taken from https://developers.google.com/maps/documentation/places/web-service/search#TextSearchRequests

Spring ServletUriComponentsBuilder and square brackets in query params

I'm trying to use Spring's ServletUriComponentsBuilder to create paging next and prev links from the current request.
The problem I'm having is that the ServletUriComponentsBuilder.fromCurrentRequest() is not unencoding percent-encoded values like:
http://example.com/articles?page%5Bnumber%5D=2
The problem is uses could have called the page with unencoded square brackets like http://example.com/articles?page[number]=2 without any problems.
Spring Data is accepting both variants (both unencoded square brackets and encoded square brackets) in it's pageable argument resolver.
This to the fact that under water the Coyote web request get parameter is used which contains the unencoded param names.
Also Spring's #RequestParam("page[number]") accepts without any problem the encoded request like http://example.com/articles?page%5Bnumber%5D=2.
From the server side I always want to return percent encoded url's as per RFC 3986.
But there does not seem a way to this as the UriComponents query params might contain both encoded en uncoded names. Because to that, if I would call encode() on the builder the already encoded query params get encoded another time, but if would contain unencoded names toURI() will fail as an unencoded [ is not allowed.
Note that the url's might contain multiple query params besides paging, e.g. for filtering.
A request could come in like:
http://example.com/articles?filter[category]=food
And would return a response with a encoded next link like:
http://example.com/articles?page%5Bnumber%5D=2&filter%5Bcategory%5D=food
My workaround it to ignore ServletUriComponentsBuilder and simply get the request url and do so custom regexp replacing.
I know this is an older question and you also found a workaround. But did you try to use ServletUriComponentsBuilder's build() method?
Some kind of the following:
ServletUriComponentsBuilder.fromCurrentRequest().build().toUriString();
I had some issues when handling JSON Strings and this helped.

GET vs POST in AJAX?

Why are there GET and POST requests in AJAX as it does not affect page URL anyway? What difference does it make by passing sensitive data over GET in AJAX as the data is not getting reflected to page URL?
You should use the proper HTTP verb according to what you require from your web service.
When dealing with a Collection URI like: http://example.com/resources/
GET: List the members of the collection, complete with their member URIs for further navigation. For example, list all the cars for sale.
PUT: Meaning defined as "replace the entire collection with another collection".
POST: Create a new entry in the collection where the ID is assigned automatically by the collection. The ID created is usually included as part of the data returned by this operation.
DELETE: Meaning defined as "delete the entire collection".
When dealing with a Member URI like: http://example.com/resources/7HOU57Y
GET: Retrieve a representation of the addressed member of the collection expressed in an appropriate MIME type.
PUT: Update the addressed member of the collection or create it with the specified ID.
POST: Treats the addressed member as a collection in its own right and creates a new subordinate of it.
DELETE: Delete the addressed member of the collection.
Source: Wikipedia
Well, as for GET, you still have the url length limitation. Other than that, it is quite conceivable that the server treats POST and GET requests differently; thus the need to be able to specify what request you're doing.
Another difference between GET and POST is the way caching is handled in browsers. POST response is never cached. GET may or may not be cached based on the caching rules specified in your response headers.
Two primary reasons for having them:
GET requests have some pretty restrictive limitations on size; POST are typically capable of containing much more information.
The backend may be expecting GET or POST, depending on how it's designed. We need the flexibility of doing a GET if the backend expects one, or a POST if that's what it's expecting.
It's simply down to respecting the rules of the http protocol.
Get - calls must be idempotent. This means that if you call it multiple times you will get the same result. It is not intended to change the underlying data. You might use this for a search box etc.
Post - calls are NOT idempotent. It is allowed to make a change to the underlying data, so might be used in a create method. If you call it multiple times you will create multiple entries.
You normally send parameters to the AJAX script, it returns data based on these parameters. It works just like a form that has method="get" or method="post". When using the GET method, the parameters are passed in the query string. When using POST method, the parameters are sent in the post body.
Generally, if your parameters have very few characters and do not contain sensitive information then you send them via GET method. Sensitive data (e.g. password) or long text (e.g. an 8000 character long bio of a person) are better sent via POST method.
Thanks..
I mainly use the GET method with Ajax and I haven't got any problems until now except the following:
Internet Explorer (unlike Firefox and Google Chrome) cache GET calling if using the same GET values.
So, using some interval with Ajax GET can show the same results unless you change URL with irrelevant random number usage for each Ajax GET.
Others have covered the main points (context/idempotency, and size), but i'll add another: encryption. If you are using SSL and want to encrypt your input args, you need to use POST.
When we use the GET method in Ajax, only the content of the value of the field is sent, not the format in which the content is. For example, content in the text area is just added in the URL in case of the GET method (without a new line character). That is not the case in the POST method.

Resources