1

We are trying to implement Reply functionality: https://developer.foursquare.com/docs/checkins/reply

We are receiving "HTTP Error 400: Bad Request" when we execute the code below. I've verified that the checkinId and oauth token are valid. (I just extracted the values from the 'checkin' data structure sent to our servers by foursquare's test console).

checkinId="508XXXXXXXXXXXXXXXXXXX"
oauth="123456789877655ADGHJETJNKK"
data = {"CHECKIN_ID":checkinId,
        "text":"Hello World!",
        "url":"https://ourwebsite.com",
        "contentId":"12345",
   }

postUrl = "https://api.foursquare.com/v2/checkins/"+str(checkinId)+"/reply?oauth_token="+oauth

data = urllib.urlencode(data)
req = urllib2.Request(url=postUrl,data=data)
resp = urllib2.urlopen(req)
print resp.read()

Any suggestions are greatly appreciated!

Think Floyd
  • 359
  • 2
  • 8
  • 14

2 Answers2

0

Try including the oauth_token in your data dictionary, instead of in the url directly. Also try removing CHECKIN_ID. If that fails, you should email api@foursquare.com with your oauth_token to see if we can diagnose the problem that way.

pfhayes
  • 3,667
  • 3
  • 19
  • 17
0

I was getting that error.

The fix for my issue was to include the HTTP header content type like this: Content-Type: application/x-www-form-urlencoded

After that I used a normal post data like this:

text="t"&url=xxx&v=20130224

I noticed the version and the url couldn't be quoted and the url needed to be HTML encoded.

David Silva Smith
  • 11,498
  • 11
  • 67
  • 91