I am sending a request to Bing Maps REST service to get the location information such as coordinates etc, I entered this request (http://dev.virtualearth.net/REST/v1/Locations/query=rsa/gauteng/2001/johannesburg/melville?o=xml&key="mykey") in my web browser (as a test) and it returns the wrong location information.
The returned xml suggests that I'm in the states somewhere in NY.
Can anyone help me understand why this is?
I have read Microsoft's documentation on the web service and I'm following the proper structure to construct a request. I have Googled in a quest of getting a solution but no luck
You're not issuing the request correctly. Bing provides two methods: structured query and non-structured. You're mixing both.
Structured ("REST" like):
http://dev.virtualearth.net/REST/v1/Locations/CA/BC/V6G/Vancouver/Stanley%20Park%20Causeway?key=BingMapsKey
Non-structured (with query-string):
http://dev.virtualearth.net/REST/v1/Locations?locality=London&postalCode=SW1A&key=BingMapsKey
As specified on the reference page (http://msdn.microsoft.com/en-us/library/ff701714.aspx) a request similar to yours would need to be done like this:
http://dev.virtualearth.net/REST/v1/Locations?countryRegion={country}&adminDistrict={district}&locality={locality}&key={key}
Also, you should use the 2-letter ISO code. Thus, South-Africa would be "ZA".
Your complete request will be:
http://dev.virtualearth.net/REST/v1/Locations?countryRegion=za&adminDistrict=johannesburg&locality=melville&key=key
It returns something like this:
address: {
adminDistrict: "Gauteng",
adminDistrict2: "Johannesburg",
countryRegion: "South Africa",
formattedAddress: "Melville, South Africa",
locality: "Melville"
},
confidence: "High",
entityType: "Neighborhood",
geocodePoints: [{
type: "Point",
coordinates: [
-26.17535972595215,
28.008920669555664
],
calculationMethod: "Rooftop",
usageTypes: ["Display"]
}]
Related
The OSRM Routing engine returns "hints" in many of its outputs, and you are able to pass these back into a new request, which saves on lookup time and thereby optimizes the query.
My question is how do I pass these "hints" back into the
/table/v1/car
API call as per the example below?
EXAMPLE:
An OSRM API request of
/table/v1/car/-0.693000,52.078000;-0.724000,52.040000
gives back (snippet) :
"sources": [
{
"hint": "uImugOqJroBBAAAAAAAAALoBAAAAAAAA7WvYQQAAAACaUzhDAAAAAEEAAAAAAAAAugEAAAAAAAAXCgAAmXb1__mxGgP4bPX_sKUaAwYALwrjJ41R",
"distance": 388.619802,
"location": [
-0.690535,
52.081145
],
"name": ""
},
The original coordinates:
-0.693000, 52.078000
have been fixed up to:
-0.690535, 52.081145
(snapped to a nearby road and the hint is as above).
So I would like to utilise these "hints" in a new API query for the same LAT/LNG location, which should optimize the query.
The manual says about hints:
This can be used on subsequent request to significantly speed up the query and to connect multiple services.
I've tried various combinations and looking at the manual, but so far nothing has worked.
Has anybody successfully passed "hint" data into the /table/v1/car
API for OSRM Routing?
If so, please would you let me know what you did
I tried your request:
/table/v1/car/-0.693000,52.078000;-0.724000,52.040000
and got response:
{"code":"Ok",
"durations":[[0,596.2],[615.9,0]],"destinations":[
{"hint":"teJ0h-fidIdBAAAAAAAAALoBAAAAAAAA7WvYQQAAAACaUzhDAAAAAEEAAAAAAAAAugEAAAAAAACrkAAAmXb1__mxGgP4bPX_sKUaAwYALwr88AjE",
"distance":388.619802,"name":"","location":[-0.690535,52.081145]},{"hint":"dbcDgLevA4BpAAAAAAAAAAQGAAAwCAAA4-dpQQAAAACIYVZDGSCSQzQAAAAAAAAAAgMAABwEAACrkAAATvb0_48VGgPg8_T_QBEaAw4Afwf88AjE",
"distance":129.943557,"name":"","location":[-0.723378,52.041103]}],
"sources":[
{"hint":"teJ0h-fidIdBAAAAAAAAALoBAAAAAAAA7WvYQQAAAACaUzhDAAAAAEEAAAAAAAAAugEAAAAAAACrkAAAmXb1__mxGgP4bPX_sKUaAwYALwr88AjE",
"distance":388.619802,"name":"","location":[-0.690535,52.081145]},{"hint":"dbcDgLevA4BpAAAAAAAAAAQGAAAwCAAA4-dpQQAAAACIYVZDGSCSQzQAAAAAAAAAAgMAABwEAACrkAAATvb0_48VGgPg8_T_QBEaAw4Afwf88AjE",
"distance":129.943557,"name":"","location":[-0.723378,52.041103]}]}
Your request has 2 points, so you have to add 2 hints, one for each point.
So, the request with hints is:
/table/v1/car/-0.693000,52.078000;-0.724000,52.040000?hints=teJ0h-fidIdBAAAAAAAAALoBAAAAAAAA7WvYQQAAAACaUzhDAAAAAEEAAAAAAAAAugEAAAAAAACrkAAAmXb1__mxGgP4bPX_sKUaAwYALwr88AjE;dbcDgLevA4BpAAAAAAAAAAQGAAAwCAAA4-dpQQAAAACIYVZDGSCSQzQAAAAAAAAAAgMAABwEAACrkAAATvb0_48VGgPg8_T_QBEaAw4Afwf88AjE
where hints are separated by semicolon.
I am designing an openAPI specification for a project. The project is a REST API that provides information about hotels.
I want to either provide detailed information about the hotel, or a quick summary. My understanding of REST is that, since both of these relate to the same object in my data store, I should be using a query parameter to request the different data types.
So what I am looking for is a way to specify different API behaviors based on query parameters of a given request. Here is my current implementation. I am looking at an endpoint like this:
/hotels/{hotelId}?detail={detailLevel}
where {hotelId} is an integer and {detailLevel} is an optional string enum that can either be summary or robust.
If detail=robust, the response should look something like this:
{
"name": "Hilton Grand Vacations on the Las Vegas Strip"
"streetAddress": "2650 Las Vegas Blvd S",
"city": "Las Vegas",
"state": "NV",
"zipCode": 89109
"rating": 4.4,
"minimumPrice": 125,
"availableRooms": 10,
}
If detail=summary, the response should look something like this:
{
"name": "Hilton Grand Vacations on the Las Vegas Strip",
"rating": 4,
"zipCode": 89109,
"available": true
}
I don't want to have a specification that covers both of these responses, because I want to make it easy to validate any given response based on its URL parameter (for example, "available" should not be a field when detail=robust). So far, I have not been able to find a way to specify different return behaviors in openAPI based on query parameters.
Is there a way to specify behavior based on query parameters? Alternatively, should I change my API endpoint to something like /hotels/{hotelId}/{detailLevel}?
To my disappointment, I have learned that openAPI does not support to use of query parameters to differentiate endpoints with the same path.
I will be specifying my paths as /hotels/{hotelId}/{detailLevel} instead.
We've recently started creating API endpoints. One of these end points is hardcoded to change 2 of our reference type codes (i.e. code: "P" for mobile is being changed to "M") from their system value to a custom value (out of a configurable list that has approximately 12 records at the moment. I'm trying to convince them it's bad practice and a terrible idea to change this reference data because of all of the issues it can cause for systems that use the api, however they believe it increases the "independence" of the API from the system of truth. We work in an enterprise environment and currently only our systems hit the api.
Is there any other data or information (Copious amounts of google searching hasn't revealed anyone discussing this sort of issue specifically) that suggests this is a bad idea? Or am I wrong in thinking so?
Edit:
For reference here's some examples:
What the data would look like in the source system the api pulls from
{
"phone_type": "P",
"phone_number": "1234567890",
"user_id":"username"
}
What that same data would look like coming from our API now
{
"phone_type": "M",
"phone_number": "1234567890",
"user_id":"username"
}
What the reference data would look like coming from our reference codes end point
[
{
"code": "P",
"description": "Mobile Number",
"active":"true"
}
]
Today i got into swagger and swagger-ui to create the documentation of our API.
We are using AWS API Gateway with a Lambda function, since AWS is comming with an in-built option for documentation we are going with it.
Sadly, I am pretty limited with this option or I am doing it wrong.
As an example
responses:
'200':
description: 200 response
schema:
$ref: '#/definitions/Empty'
I canĀ“t create an alternative schema, nor im able to edit the existing /Empty schema.
Is there a solution for my problem?
For example
... to not use an schema and just write the whole response in there?
... to show me how to create an alternative schema?
EDIT
For me it seems like an AWS problem, not my swagger file in generall. If someone reads over this i added more informations.
It doesnt matter if i use "create Documetation Part" --> Type = Response (Body) or i go to Ressources --> Method which i want to set the Response (Body) --> Method Response and set the Respone Body to an Modell.
My Modell looks like this
{
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description" : "Example Promotion",
"title" : "Promotion",
"type" : "object",
"properties" : {
"Status" : { "type" : "string"}
}
}
}
It gives me no error, but if i go to "Publish Documentation" it seems to no put the Respone (Body) i set into the swagger.json on the Method Response part, nor on the Defenitions at the end of the file and set the schema path right.
I found it easier to not use $ref when I was starting out. After you have the knack how to write requests or response definitions, you can easily transition to referencing schemas using $ref.
What comes after schema statement? That depends on what you expect to be returned -- text, an array, a JSON object, or an array of JSON objects, etc. Typically it's the later two. So here is an example of each.
schema:
type: object
description: This is a JSON object
properties:
fullName:
type: string
age:
type: number
which defines: { fullName: "Jane Smith", age: 30 }
schema:
type: array
description: This is an array of JSON object
items:
type: object
properties:
carMake:
type: string
carModel:
type: string
which defines: [{ carMake: "Ford", carModel: "Mustang" } ... ]
Clone github's swagger-ui onto your computer and run it as a local server. Or you have free use of the SwaggerHub if you don't mind the API definition to be public (or, after a trial period, pay for your APIs to be private).
The specification has changed over the years, so its important to know whether you are dealing with swagger v2 or openapi v3. www.swagger.io has a good multi-page tutorial. And you can find several public API examples at the SwaggerHub website. I do not work for Smartbear, the originators of both the original swagger spec and swaggerhub tooling, but I've found them to be very helpful in the past. Some of their staff monitor this website and answer questions.
Good luck!
I am attempting to pass information collected as, "custom dimensions," from Google Tag Manager through Google Analytics and then extract them out via the Google Analytics V4 API.
I have set up four of the fundamental custom dimensions suggested by Simo Ahava in this article.
My variable setup looks like the following:
variable setup
Essentially, I have been able to successfully pass through userID_dimension, hittimestamp_dimension, clientid_dimension and sessionid_dimension to the Google Analytics dashboard, but for some reason I am not able to extract out the hittimestamp_dimension through the API.
Here's what I am able to see on the dashboard:
Google Analytics Dashboard
As far as the API itself, I am using the HelloAnalytics.py python version supplied by Google, and I am able to extract out all of the above information, minus the timestamps dimensions on the right hand side of each.
I'm storing the timestamp information in dimension2, but upon making the below call (again, using API V4) I get blank...nothing.
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}]
}]
}
).execute()
Upon making this call, one would expect that the above would report out dimensions similar to what the Google Analytics dashboard would show. E.g. one would think that the dashboard itself is using the API. However what prints out is blank. All other custom dimensions print out as expected.
If I try to call the above function on just dimension2 itself with no other dimension, it is also blank.
Is there something special one has to do in order to extract hit-scoped variables within the API? Or does the API just not allow hit-scoped variables to pass through?
thanks,
You forgot to add a 'metrics' field to your request, it is required as per documentation
Source: Reporting API v4 - Method: reports.batchGet
The metrics requested. Requests must specify at least one metric. Requests can have a total of 10 metrics.
The below modified request should work:
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}],
'metrics': [{'expression': 'ga:sessions'}]
}]
}
).execute()