Pandaiolo Pandaiolo - 2 years ago 101
Node.js Question

Podio file attached to item cannot be downloaded

I have an issue trying to download files attached to Podio items:

podio.request('get', '/file/{file_id}/raw').then(console.log);

The above program displays:


This is a JSON stringified empty object (instead of raw file content).


  • The above file can be accessed with its URL when logged in

  • The above code is run after proper authentication

  • It actually works when using a
    from an image field of the item, but not from a file attachment (pdf files in my case).

  • When using API endpoint
    to get a list of items, the property
    is set, but not
    . I have to request
    individually to get the
    property included in the response, not sure why.

Question: Do you know what is the issue, and how I can download raw attached files?

EDIT: aditionnal info

If I request a single file metadata using the folowing command:

podio.request('get', '/file/1234').then(console.log);

I get a file JSON object which includes many fields, but not the file content :

link: '',
file_id: 1234,

As stated in my comment to @stengaard, if I try to request the API for the above link, here is the response :

{ [PodioNotFoundError: [object Object]]
{ error_parameters: {},
error_detail: null,
error_propagate: false,
{ url: '',
query_string: '',
method: 'GET' },
error_description: 'No matching operation could be found. The path \'/1234\' was not found..',
error: 'not_found' },
status: 404,
url: '',
name: 'PodioNotFoundError' }

Answer Source

To use the GET /file/{file_id}/raw endpoint you need an API key with elevated trust levels.

Instead use GET /file/{file_id} endpoint. That contains a link attribute (a URL) you should follow to get the file content.

The link attribute will look like:{file_id}. To fetch the file do{file_id}?oauth_token={oauth_token}. Where the OAuth token is the same as the one used to GET /file/{file_id}. If you know the file ID (e.g. from a GET /item/{item_id} you can skip the GET /file/{file_id} and contact directly. (Note: You can also set the Authorization: OAuth2 {oauth_token} header in your HTTP request if you don't like passing the auth token in a URL paramter.)

For an example on how to use it see

Typically in the JS client, if you use podio as your Podio API object, the OAuth token would be located there:


So to get the raw content of the file in nodejs:

var url = ''+file_id+'?oauth_token='+podio.authObject.accessToken;
request(url, function (err, fileContent) {
    // use fileContent here, write to a file, etc...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download