Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JohnSwid
New Member

Connecting to data source hosted on Dropbox

Hello PowerBI-Ites,

 

Has anyone had any luck connecting to Dropbox as a data source.  Couldn't find many articles on this topic.  Here's one  article that had a solution we couldn't get to work: http://community.powerbi.com/t5/Desktop/Data-source-hosted-on-Dropbox/td-p/47882.

Just wondering if anyone could shed some light on this topic.  Thank you!

 

58 REPLIES 58

Sorry @Anonymous! The example I used to implement this was a company production report. I'd have to make a test example, but I can do it with a little spare time today or tomorrow if you're still stuck. 

 

It is api v2. My instructions tell you to get the access token via the API Explorer link on the home page of dropbox.com/developers. Ctrl+F your way to "list_folder" and click on Get Token and follow the instructions to get a token for what you need. In my situation I have both a personal account and a company one, so I have to choose before I can generate a token. 

After that you have the query step in powerbi desktop. This line is all you need and then you can go on and navigate to the excel sheets you're interested in. Nothing else. 

= Excel.Workbook(Web.Contents("https://api-content.dropbox.com/1/files/auto/<PATH FROM DROPBOX ROOT TO EXCEL OF INTEREST>/<EXCEL FILENAME>?access_token=<ACCESS TOKEN GENERATED FOR THE DROPBOX ROOT YOU'RE IN>"), null, true)"

So in context, my M code looks like:

let
    Source = Excel.Workbook(Web.Contents("https://api-content.dropbox.com/1/files/auto/<PATH FROM DROPBOX ROOT TO EXCEL OF INTEREST>/<EXCEL FILENAME>?access_token=<ACCESS TOKEN GENERATED FOR THE DROPBOX ROOT YOU'RE IN>"), null, true), 
    Assignments_Sheet = Source{[Item="Assignments",Kind="Sheet"]}[Data], 
    #"Promoted Headers" = Table.PromoteHeaders(Assignments_Sheet, [PromoteAllScalars=true]),
    and so on...

 

Anonymous
Not applicable

JAkerblom, I really apreciate if you could test the list_folder command for me.

once I can connect to Dropbox using my token and view all files, I can handle them myself. but first I need to connect to the files and view them inside PBI query editor.

 

using web query or M language, I am having issue to make it work with my token and the supposed-to-be link below.

https://api.dropboxapi.com/2/files/list_folder

 

as I learned in Dropbox,

API v1 is: api-content.dropbox.com/1/etc

API v2 is: api.dropboxapi.com/2/etc

This is why I believe your code is using the old v1 API.

https://www.dropbox.com/developers/reference/migration-guide

Follow these images below.

And second, you're not supposed to use that link as you implied. Use the one I mentioned, and use it the way I described and all will be alright.

https://api-content.dropbox.com/1/files/auto/<Path to file>?access_token=<token>

2017-08-09 15.44 In Dropbox developers home page.PNG2017-08-09 15.46 In API Explorer.PNG2017-08-09 15.48 In the list_folder page.PNG

Anonymous
Not applicable

yes, I followed these steps correctly, but this link only works when a file name is provided.

I created a new token for the new command list_folder.

 

I don´t want to load a single file, I need to load the contents of a folder, and view all files inside the folder.

I tried many times, many different codes. I got a lot of errors each test: 400, 404 and 405.

And so far nothing is loaded.

Anonymous
Not applicable

thanks for your reply.

only today I got time to test it, and I couldn´t make it work.

I found the list_folder under API Explorer, got the HTML code, but I cannot insert it in the other web queries from the other posts.

could you please send an example of your working code?

Anonymous
Not applicable

masplin, IT WORKED!!! thanks a lot!

No more credential errors, dropbox api v2 and PBI Service working as they should!

great!

masplin
Impactful Individual
Impactful Individual

Out of interest what were you trying to do?  If you just put the path to the dropbox folder like normal then it shoudl stil lwork as long as the path is the one on which your gatewayis running.  Theo nly advantage of the method i put is you can open desktop on various machines, where dropbox will have differnet paths, and still refresh them locally.

Anonymous
Not applicable

I need to connect dropbox cloud directly to PBI cloud. This way, me and my team will be able to use only the PBI Service to see all data that was edited by everyone.
example, user A may change all files 1, 2 and 3, also user B and C may change all 3 files.
once dropbox gets them updated, all 3 users will use only the PBI Service to see the updated changes.

 

now comes my new question: how to make it open full folders, intead of individual files? something like folder option on PBI Desktop.

I need to connect dropbox cloud directly to PBI cloud. This way, me and my team will be able to use only the PBI Service to see all data that was edited by everyone.

 

Can you say me if you could solve it?

masplin
Impactful Individual
Impactful Individual

ah when you work that out let me know!!!

 

Have you tried Imke solution where you create a folder under Apps?  That's what i was going to try next.

Anonymous
Not applicable

didn´t tried that yet... but I will try it soon.

Thanks to you I am finally able to call data from Dropbox. I built upon your list_folder API call , added a download call after it:

 

- Actual data table would be:

 

let
    header = [  #"Authorization"="Bearer "&token,
                #"Content-Type"="application/json"],
    data = [    path="",
                recursive=true,
                include_media_info=false,
                include_deleted=false,
                include_has_explicit_shared_members=false],
    response = Web.Contents("https://api.dropboxapi.com/2/files/list_folder",[Content=Json.FromValue(data),Headers=header]),
    out = Json.Document(response,1252),
    entries = out[entries],
    #"Converted to Table" = Table.FromList(entries, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {".tag", "name", "path_lower", "path_display", "id", "client_modified", "server_modified", "rev", "size", "content_hash"}, {".tag", "name", "path_lower", "path_display", "id", "client_modified", "server_modified", "rev", "size", "content_hash"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Column1", each ([#".tag"] = "file")),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "file", each fGetTable([path_display])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{".tag", "name", "path_lower", "path_display", "id", "client_modified", "server_modified", "rev", "size", "content_hash"}),
    #"Expanded data" = Table.ExpandTableColumn(#"Removed Columns", "file", {"COLUMN1 HERE", "COLUMN2 HERE"}, {"COLUMN1 HERE", "COLUMN2 HERE"})
in
#"Expanded data"

 

- keep in mind you have to type your expanded columns manually, user interface expanding does not seem to work with this method...

- "token" (line 2) is a defined parameter with the actual generated access token for the Dropbox application, you could type it between quotes as text right there instead.

 

- fGetTable function, which is the actual download query (referenced in line 15) would be:

 

 

let GetFile=(file) =>    

let
    header = [  #"Authorization"="Bearer "&token,
                #"Dropbox-API-Arg"="{"&""""&"path"&""""&":"&""""&file&""""&"}"],
    out = Web.Contents("https://content.dropboxapi.com/2/files/download",[Headers=header]),
    excel = Excel.Workbook(out, null, true),
    table = excel{0}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(table, [PromoteAllScalars=true])
in
    #"Promoted Headers"

in GetFile

  

The "Dropbox-API-Arg" was escaping-quotes hell...

Edit: double quotes is one escaped quote inside a string... didn't need so much escape and concatenate, just changed that line to:

 

#"Dropbox-API-Arg"="{""path"":"""&file&"""}"],

Hi @gparrello I'm glad that it helped you.

Not sure what you mean that you have to type the column names yourself. I'm sure that you can work out some automated solution. If you need help, just start a new thread and I'll look into it.

Thanks so much @gparrello and @hugoberry for sharing your findings.  Am I right in understanding that this will only work on folders owned by the Developer who generates the Dropbox app & access key?

 

I want to point Power BI at a Dropbox folder that's been shared with me.  So I dont know the full folder path.

@mike_honey you are correct, you would only be able to access folders owned by the creator of the API key.

But, as far I know, you also own a copy of any shared folder (it's in your Dropbox path) and shared folders are movable (you can put a shared folder inside any subfolder of yours, it doesn't have to be in the root of your Dropbox).

I believe you could create a folder and an API key for it and then move the shared folder inside it.
ankitpatira
Community Champion
Community Champion

@JohnSwid You need to register for Dropbox developer account and generate access token. Then use URL provided as below to connect. FILE PATH is folder/filename.extension. When you register app for access token choose full permission and it should work.

 

https://api-content.dropbox.com/1/files/[FILE PATH]?access_token=[ACCESS TOKEN]

 

https://api-content.dropbox.com/1/files/abc/myfile.txt?access_token=12345 where abc is folder, myfile is file and 12345 is access token.

Greg_Deckler
Super User
Super User

When you said that it didn't work, what kind of error/issue were you seeing?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors