cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

How to get file content using rest api?

Explorer | Level 3

How to get file content using rest api ?

 

9 Replies 9
Highlighted

Re: How to get file content using rest api?

Dropboxer
Dropboxer

To access file content via the Dropbox API, you should use the /2/files/download endpoint.

Highlighted

Re: How to get file content using rest api?

Explorer | Level 3

Hi,

 

Please provide me one of example because i tried with same API it did not give me files content

Highlighted

Re: How to get file content using rest api?

Dropboxer
Dropboxer

There's a code example for calling this endpoint using curl in the documentation, and you can also generate some code for calling it using the API v2 Explorer.

If something isn't working as expected, please share the code you're using and the unexpected error or output.

Highlighted

Re: How to get file content using rest api?

Explorer | Level 3

Hi,

i am getting content like this in error.

Please suggest me if i am doing something wrong.

code.pngerror.png

Highlighted

Re: How to get file content using rest api?

Dropboxer
Dropboxer

The error is indicating that you're trying to parse some data as JSON, but the data isn't in a valid JSON format, so the parsing is failing.

I don't see anything that mentions Dropbox in the error screenshot, nor do I see anywhere that the stack trace in the error that references the code you posted, so I can't offer much insight. You'll need to debug your app more to track down where/why this is occuring. 

Highlighted

Re: How to get file content using rest api?

Explorer | Level 3

I tried same thing with xslx files . Can you help with example on that?

Highlighted

Re: How to get file content using rest api?

Dropboxer
Dropboxer

@Chhavi Downloading file content via the Dropbox API works the same way, regardless of file type. You can use the /2/files/download endpoint to download file data whether the file is a .xlsx or any other type. Exactly what you then do with the data is up to you. For example, you may wish to open the data in a document viewer.

If something isn't working as expected, feel free to open a thread with details.

Highlighted

Re: How to get file content using rest api?

Explorer | Level 3

I am still not able to get data for .xslx file. This is preview here! how to get content from this?Screenshot from 2019-12-05 22-47-06.png

Highlighted

Re: How to get file content using rest api?

Dropboxer
Dropboxer

@Chhavi That is the file data for the requested file returned by the Dropbox API. The /2/files/download endpoint is a "content-download" style endpoint, meaning it returns the requested content in the HTTPS response body. You can use or save the response body however you wish. Exactly how you do so will depend on what HTTPS client/library you're using.

We can't provide support for third party clients/libraries, but it looks like you're using Postman in your screenshot, which I believe has a "Save Response" button (not visible in your screenshot though).

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?