Skip to content Skip to sidebar Skip to footer

Foursquare Missing File Upload / Invalidphotoformat Error While Uploading Photo Through Api

I'm trying to add a photo to foursquare page using api: https://api.foursquare.com/v2/photos/add and following node.js code: var accessToken = 'myAccessToken';

Solution 1:

These are the request options that worked for me:

var options = {
    'url': 'https://api.foursquare.com/v2/photos/add',
    'qs': {
        'v': '20161001',
        'oauth_token': ACCESS_TOKEN,
        'venueId': VENUE_ID
    },
    'formData': {
        'file': {
            'value': RAW_IMAGE_BUFFER,
            'options': {
                'filename': 'topsecret.jpg',
                'contentType': 'image/jpg'
            }
        }
    },
    'json': true
};

Then just call:

request.post(options, function(error, response, body){})

Solution 2:

photo parameter does not exist. photo is response field.

The image data is sent as the POST message body on the HTTP request.

EDIT

You use request? Refer to https://github.com/request/request#multipartform-data-multipart-form-uploads

You don't need encode into base64.

Post a Comment for "Foursquare Missing File Upload / Invalidphotoformat Error While Uploading Photo Through Api"