Foursquare API mayorships are always empty? - api

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

Related

Why I only getting id's back in response? IGDB api

I already read the documentation and I think I am making the simplest request in the correct way, but it always returns only the IDs, instead of all the fields of the games
Documentation example: Documentation Example
The request header is fine. I know this because I can get the expected request if fields = * as querystring
this is my request:
You have to provide the fields you want inside the body.
Like this:
fields age_ratings,aggregated_rating,aggregated_rating_count,alternative_names,artworks,bundles,category,checksum,collection,cover,created_at,dlcs,expansions,external_games,first_release_date,follows,franchise,franchises,game_engines,game_modes,genres,hypes,involved_companies,keywords,multiplayer_modes,name,parent_game,platforms,player_perspectives,rating,rating_count,release_dates,screenshots,similar_games,slug,standalone_expansions,status,storyline,summary,tags,themes,total_rating,total_rating_count,updated_at,url,version_parent,version_title,videos,websites;"

How to get maximum number of tweets on an user

i have this code
("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500'
But it is giving me only 200 records , I found in twitter document that it will give 3200 tweets.Is i am doing wrong what should i do to get that much tweet.
Since there is no page system in twitter 's API, to go throught timelines, you must use the "max_id" parameter.
Here is an helpful link that explains how to work with timelines with nice illustrations: https://dev.twitter.com/rest/public/timelines.
Edit: here is how you do it.
"To use max_id correctly, an application’s first request to a timeline endpoint should only specify a count."
Make your request "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500 (you can put 200).
Then when you get all your data, " keep track of the lowest ID received" and use it as parameter (the same way you do for the count) for your next request. it will give you the 200 next posts with a lower id than the one you specified. Do it again until you reach the end.

Correct response on a request for multiple objects where one does not exist

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.

Restful api structure

Simply, what's better?
API Methods:
GET videos/getall
GET videos/get?id=1
GET news/getall
GET news/get/?id=1
GET blogs/getall
GET blogs/get?id=1
OR
GET content/getall/?type=videos
GET content/getall/?type=news
GET content/get?id=1&type=blogs
First way isn't look like DRY. But it has some advatanges. So what way is better?
All of these URIs are wrong. They include action information(i.e. getall and get) which turns your URIs into regular RPC calls.
You can choose simpler approach:
GET /videos
GET /videos/1
GET /news
GET /news/1
GET /blogs
GET /blogs/1
HTTP GET already means that you are retrieving data.

"Unprocessable entity" when trying to change the fulfilment status of an order IN SHOPIFY

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?