Reply
Frequent Visitor
Posts: 2
Registered: ‎03-01-2017

Re: Connecting to data source hosted on Dropbox

@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.
Member
Posts: 108
Registered: ‎04-14-2017

Re: Connecting to data source hosted on Dropbox

I tried your code and got this error. I just created an app and added the access code where you had zzzzzzz.

 

DataSource.Error: Web.Contents failed to get contents from 'https://api.dropboxapi.com/2/files/list_folder' (400): Bad Request
Details:
DataSourceKind=Web
DataSourcePath=https://api.dropboxapi.com/2/files/list_folder
Url=https://api.dropboxapi.com/2/files/list_folder

 

Any ideas what this means?

 

Thnaks

Mike

Member
Posts: 108
Registered: ‎02-03-2017

Re: Connecting to data source hosted on Dropbox

I have created a DropBox data connector using the Power Query Extensions SDK. You are welcome to try it or check the code for a possible answer
https://github.com/Hugoberry/PowerQueryConnectors/blob/master/src/DropBox/DropBox.pq
Member
Posts: 108
Registered: ‎04-14-2017

Re: Connecting to data source hosted on Dropbox

Actually I managed to set up the new personal gateway so that i coud use the files on dropbox as a data source for a PBIX file

 

I think thisis doing somethnig different? Coudl you just explain in what instances I woudl be looking to use this for futre refernece?

 

Thnaks

Mike 

Super Contributor
Posts: 1,053
Registered: ‎09-06-2015

Re: Connecting to data source hosted on Dropbox

Hi guys,

thanks for these helpful different solutions! I've picked up some code bits from this thread and created a function that makes it pretty easy to grab files from a dropbox-folder: https://www.youtube.com/watch?v=eEVRO-Zc7pg

 

This should be helpful for folks who are not so tech-savy and might stumble across this post.

DN Member
Member
Posts: 140
Registered: ‎11-21-2016

Re: Connecting to data source hosted on Dropbox

[ Edited ]

Thanks a lot for your code Imke!
But would you have a compact version of it? without the function parameters...

Because your code is a function, the Gateway does not work. I get credential errors.

 

I am loking for just the direct link, something like the first comment on this idea.

But I couldn´t make it work this example in the comments...
https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/6663925-dropbox (opens in new tab)

Super Contributor
Posts: 1,053
Registered: ‎09-06-2015

Re: Connecting to data source hosted on Dropbox

[ Edited ]

Not sure if I understood you correctly (and very much doubt that that's the reason), but here you go: Function converted to "ordinary" query:

 

//let Source=
//(token as text, optional folder as text) => 

let
token = "<<FillInYourTokenHere>>",
folder = null, // replace null with folder name if you want to use it
    data = [    path= if folder = null then "" else folder,
                recursive=false,
                include_media_info=false,
                include_deleted=false,
                include_has_explicit_shared_members=false
],
    header = [  #"Authorization"="Bearer "&token,
                #"Content-Type"= "application/json"],
    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],
    ToTable = Table.FromList(entries, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    ExpandProperties = Table.ExpandRecordColumn(ToTable, "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"}),
    RetrieveContent = Table.AddColumn(ExpandProperties, "File", each Web.Contents("https://content.dropboxapi.com/2/files/download",[
    Headers=[#"Dropbox-API-Arg"="{""path"":"""&[path_display]&"""}", #"Authorization" = header[Authorization]]]))

in
RetrieveContent 

/*
,documentation = [	
Documentation.Name =  "	fnDropbox.Folder
", Documentation.Description = "	Returns a table with contents from your selected Dropbox folder
" , Documentation.LongDescription = "	Returns a table with contents from your selected Dropbox folder. The optional field 'folder' allows you to access sub-folders within the main folder.
", Documentation.Category = "	Accessing data functions
", Documentation.Source = "	local
", Documentation.Author = "	Imke Feldmann: www.TheBIccountant.com
", Documentation.Examples = {[Description =  "	
" , Code = "	Check this blogpost explaining how it works: http://wp.me/p6lgsG-AA
 ", Result = "	
"]}]	
 in	
  Value.ReplaceType(Source, Value.ReplaceMetadata(Value.Type(Source), documentation))
*/

 

DN Member
Member
Posts: 140
Registered: ‎11-21-2016

Re: Connecting to data source hosted on Dropbox

yes Imke! thanks for the ordinary query! it was exactly what I wanted!
but somehow, there is still error on gateway...

 

I need to make a Power BI project where the data comes from Dropbox cloud straight to Power BI cloud (service).

the project needs to use only the token, so any other user may open the file hosted in dropbox´s cloud.

using both your codes, I get the exact same error on credentials.

for the sencond code, I started a brand new file on power BI, this way there are no leftovers from the first code.

I think this error is a limitation from the Power BI Service´s Gateway...

 

Maybe we need to put all parameters inside a single URL:

 

how it is now:

Web.Contents("https://api.dropboxapi.com/2/files/list_folder",[Content=Json.FromValue(data),Headers=header]),
out = Json.Document(response,1252)

 

how it might be to make it work:

Web.Contents("https://api.dropboxapi.com/2/files/list_folder/data/token",),
out = Json.Document(response,1252)

 

what do you think?

 

 

 

dropbox gateway error.png

Super Contributor
Posts: 1,053
Registered: ‎09-06-2015

Re: Connecting to data source hosted on Dropbox

Sorry, but I have no experience with the data gateway.

You might consider posting that question in the Service-Forum or in the Integrations-forum: http://community.powerbi.com/t5/Integrations-with-Files-and/bd-p/power-bi-services 

Frequent Visitor
Posts: 8
Registered: ‎02-27-2017

Re: Connecting to data source hosted on Dropbox

I'm having the same problem as the previous poster (DN). It can't connect anymore once it's published to the Power BI Service. 

 

It doesn't matter if it's your solution ImkeF or if I'm just doing a web connection through the string;

https://api-content.dropbox.com/1/files/auto/<path to file in app folder>?access_token=<access token>

It works fine locally and I can get the data source from both alternatives, but it's the published version that is erroneous.

 

Is this a scenario that they just haven't taken into account? That I'd actually like to publish my report to PowerBI and be able to refresh the report from there? It just seems silly to me.