I would like to get data about city bikes - Dublin bikes- a bike sharing scheme run by JC Decaux. The information is available in real time from their website via an API. I have never gotten information from an API and cannot seem to work it.
I am using hurl.it just to check the structure of what I am requesting. I am attempting to get a list of the stations as denoted here: (https://developer.jcdecaux.com/#/opendata/vls?page=dynamic)
With this HTTP request:
GET https://api.jcdecaux.com/vls/v1/stations HTTP/1.1
Accept: application/json
I have put
https://api.jcdecaux.com/vls/v1/stations&apiKey={apikey} HTTP/1.1
into the "Destination" field. and "Accept" and "application/json" into the two "Header" fields.
I have tried many variations of this and nothing is giving me anything other than a 404 Not Found response. I am using an actual key for the api key after signing up.
Am I using this hurl.it site correctly?
First you need to get an API Key. Go to
https://developer.jcdecaux.com
to get one.
You can use your key in the URL like so: https://api.jcdecaux.com/vls/v1/stations?contract=dublin&apiKey=yourapikey
Related
I've found several posts looking for guidance on how to use the Spotify Add Custom Playlist Cover Image API, but no responses with examples of how to use it successfully (for example). Zero responses to a recent question about this on the Spotify developers community forum.
Has anyone actually succeeded in making this work? Can you share an example?
I'm making a PUT call to https://api.spotify.com/v1/playlists/{my playlist ID}/images with headers Accept: application/json, Content-Type: image/jpeg (I've also tried application/json), and Authorization: Bearer {token}
I've encoded my image filed with base64 and confirmed there's no preface text with image/jpeg. My question is how to actually post the encoded image data? I don't think it's part of the URL call (https://api.spotify.com/ ... /images/image=), but rather in the request body. All of my various attempts are generating a 400 error: "Bad request"
Appreciate any help out there.
I encounter the following case:
I have an API that allows me to retrieve a unique resource:
GET myapi/resource_id
If this resource does not exist, I return a 404 HTTP status code.
This API also allows to retrieve several resources via the same request:
GET myapi/resource_id1,resource_id2
Which HTTP status code should I send back if one of the two resources does not exist?
200 with an explanation in the JSON in an error key
206 which allows to be more explicit with an explanation in the JSON in an error key
400 / 404 code but this is not fine because the API still returns one of the two information
another solution?
Thank you for your help.
I think there are 2 options here.
Send back 200 and don't even mention the missing resource.
Send back 404 with an empty body.
The 206 is for range requests, the 400 is for malformed requests, so none of those apply here.
I'm trying to use the Places (Search) API (or any HERE API for that matter) for the first time. I tried the example in this page and got this page as a response:
https://places.cit.api.here.com/places/v1/browse?app_id=YOUR-APP-ID&app_code=YOUR-APP-CODE&in=52.521,13.3807;r=2000&cat=petrol-station&pretty
I don't know what I'm missing here but, I expected to get a plain JSON/XML response (orange rectangle), like this example of the Routing (Isoline) API which outputs this to the browser:
https://isoline.route.cit.api.here.com/routing/7.2/calculateisoline.json?mode=fastest;car;traffic:disabled&jsonAttributes=1&rangetype=time&start=34.603565,-98.3959&app_id=YOUR-APP-ID&app_code=YOUR-APP-CODE&range=1800
this way I could consume the service using the JSON/XML output.
I already tried both examples above in my Spring (JAVA) app and the second one works as expected, while the first one throws error (as expected).
HERE API newbie here, help appreciated.
PS: this project app of mine is just about finding nearby POIs (e.g: gyms, coffee shops, pharmacies, cinemas, etc). So, any suggestions on what API is best to go with for this, also very appreciated.
I don't know the HERE api but from having a quick look it seems they generate your results depending on the Accept header in your http request.
By default my chrome sends this accept header:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
If I use Postman to send the request without any Accept header or Accept: application/json it returns the json results.
If I add an Accept: text/html header to the request in Postman it sends me the PlayPen in html.
You can also see in their documentation that they use the appropriate Accept: application/json
I suggest you use Postman to test and play with the API's.
Assume the url is
www.example.com
I'm trying to make a post request using Postman to the following API.
sample1, /sample2, ...,/sample10
I can't figure out what's that mean. Should I put api as key, and /sample1 in the params? Or put them in the header? Thanks
Your setup would be:
/sample1 sample10 are just parts of the url you're posting to. To add the header click on the header tab and add a key/value for the headers you want to send.
Here's the API.
This is my first time working with web APIs so bear with me. Where do the name-value pairs listed under each call belong in my HTTP request? Do they go in the URL, the headers, or the body? Is it different depending on if it's a GET request or a POST?
Are the answers to these questions true in general, i.e. for any web API?
Where do the name-value pairs listed under each call belong in my HTTP request?
In a GET, they're in the URL's query string. in a POST, they're in the request body. Headers never contain request parameters, but things like Content-length do control them, a bit. You might also run across JSON in a POST body (I can't remember if reddit does this). This is not reddit-specific, and is standard HTTP.