[Solved] How to use python-request to post a file on a Rails App


I figured it out:

def add_photo(entry_id, image_path):

    return requests.post(
        url     = URL,
        headers = HEADER,
        files   = {
            'entry[entry_id]': (None, entry_id, 'text'),
            'entry[photo]': (os.path.basename(image_path), open(image_path, 'rb'), 'image/jpg', {'Expires': '0'})
        }
    )

solved How to use python-request to post a file on a Rails App