Joe Beuckman
Joe Beuckman

Reputation: 2296

Example of POST to foursquare API?

I'm trying to add a new checkin but I can't figure out how Foursquare wants the to receive the parameters. I have tried a url-encoded string in the body:

shout=test&venueId=4a663032f964a5202fc81fe3

And I have tried a JSON string in the body (with application/json Content-Type header):

{"shout":"test","venueId":"4a4a9f71f964a52004ac1fe3"}

But, I always get the error response:

meta =     {
    code = 400;
    errorDetail = "Must provide parameter venueId";
    errorType = other;
};

What is the correct way to POST to their checkins/add endpoint?

Upvotes: 1

Views: 787

Answers (2)

David Silva Smith
David Silva Smith

Reputation: 11716

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.

Upvotes: 0

pfhayes
pfhayes

Reputation: 3927

The venueId must be sent as a POST parameter. The precise method of doing this will depend on the library/language you are using.

For example, to do this using CURL on the command line, you would use

curl https://api.foursquare.com/v2/checkins/add -F venueId=<the id> -F oauth_token=<the token>

Upvotes: 2

Related Questions