Hi folks,
I'm new to the Four Square developer community. I'm playing around
with the apis, but I cannot get a simple search api to work. Here are
the steps I've completed:
1. created a new application on four square (i saved my client_id and
client_secret)
2. created a simple console application in .Net
3. wrote the below function to try and get nearby coffee shops for a
latitude and longitude coordinate:
HttpWebRequest request = null;
HttpWebResponse response = null;
StreamWriter sw = null;
StreamReader sr = null;
string apiUrl = "
https://api.foursquare.com/v2/venues/
search";
string responseResult = "";
string ll = "-22.9303205,-43.1812857";
//category id for Coffee Shops.
string categoryId = "4bf58dd8d48988d16d941735";
string clientId = "XXX_MY_CLIENT_ID_XXX";
string clientSecret = "XXX_MY_CLIENT_SECRET_XXX";
string postData = "ll=" + ll + "&categoryId=" + categoryId
+ "&client_id=" + clientId + "&client_secret=" + clientSecret;
//make api request
request = (HttpWebRequest)HttpWebRequest.Create(apiUrl +
"?" + postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US;) Firefox MyTestApp";
request.Accept = "application/json, application/xml";
//NOTE: When trying to call GetResponse() I get an
exception with the message "Error (405) method not allowed"
response = (HttpWebResponse)request.GetResponse();
sr = new StreamReader(response.GetResponseStream());
responseResult = sr.ReadToEnd();
return responseResult;
Does anyone have any advice on what I am doing wrong?
Thanks.