cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you using the Microsoft co-authoring beta for Dropbox? Share your feedback and learn more about it here.

Discuss Dropbox Developer & API

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

Get a folders public link using the dropbox API in Azure logic apps

Get a folders public link using the dropbox API in Azure logic apps

Jeff B.63
Collaborator | Level 8
Go to solution

We use Dropbox to store pictures from every jobsite we work on.  The estimator puts his pics in the folder for the crews to view and later the crews put their images in the same folder.  I have been using an Azure logic app to create the folders I need by using a constructed folder path and creating a txt file. I then delete the file afterwards.   But I can't find any way to get the public link for the folder using Logic Apps. 

 

 

I can do it in Zappier but that just gets stupid expensive in short order. 

 

Has anyone found a way to get the public link?

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20

@Jeff B.63 wrote:

The example in the blog uses curl but I need HTTP.  I tried the online conversion tool from GitHub but it just gets syntax errors.  ...


Hi @Jeff B.63,

You can add -v option (verbose) in every curl command and you'll get entire HTTP request in the console output as is. 😉

 


@Jeff B.63 wrote:

...  I have my AppKey and AppSecret but what is the authorization code and do I need a redirect URI since I want the response to come right back to the HTTP request?


The authorization code is something you should receive from the authorization page where you (or your application user - whoever is) grant permission to access account resources. It can be copied by hand or received automatic using redirect URI - the choice is yours. So, no, it's not mandatory usage of redirect URI. Take a look here how you can perform the same without redirect URI.

Hope this helps.

View solution in original post

24 Replies 24

Greg-DB
Dropbox Staff
Go to solution

The Dropbox API does offer the ability to create and retrieve shared links programmatically.

 

To create a shared links for a file or folder, you should call the /2/sharing/create_shared_link_with_settings endpoint. To retrieve existing shared links, you would call /2/sharing/list_shared_links.

 

By the way, those are links to the documentation for the HTTPS endpoints themselves, but we recommend using one of the official SDKs if possible. Those have corresponding native methods for the HTTPS endpoints.

Jeff B.63
Collaborator | Level 8
Go to solution

This is a little outside my wheelhouse but I am giving it a go.  This is what I have tried but something is wrong and I am not sure if I am on the right track or not.  Some guidance would be appreciated.

Dropbox api call.png 

Here is the raw input:

{
    "method""GET",
    "queries": {
        "direct_only""true",
        "path""/~ Pictures - All/2023/236056 - 459 Jellicoe Cres/"
    },
    "headers": {
        "Authorization""*sanitized*",
        "Content-Type""application/json"
    }
}
 
And here is the raw output:
{
    "statusCode"404,
    "headers": {
        "Date""Mon, 24 Apr 2023 20:37:35 GMT",
        "Server""envoy",
        "Vary""Accept-Encoding",
        "X-Dropbox-Response-Origin""far_remote",
        "X-Dropbox-Request-Id""43295fb3e28a44578e11c9600a9e2579",
        "Transfer-Encoding""chunked",
        "Content-Type""text/html"
    },
 
Error (404) We can't find the page you're looking for. 
}

Здравко
Legendary | Level 20
Go to solution

@Jeff B.63, Take a look on documentation! There POST request is always used. 🙋 GET is not for listing. The call parameters have to reside in request body, JSON encoded (as you correctly have specified in a header). Where is this JSON right now? 🧐😉

Greg-DB
Dropbox Staff
Go to solution

@Jeff B.63 As Здравко noted, your request is not formatted properly. You can find information on how to call the endpoint in the documentation. The API v2 Explorer can also be useful for prototyping these calls; you can click "Show Code" to see how the call would be constructed in a few different clients.

Jeff B.63
Collaborator | Level 8

After a long while I am finally getting back to this issue.

I have tried the API v2 Explorer and can get the call to work but when I view the code for HTTP, my logic app has all the same content with the exception of User-Agent which in the Explorer shows as

User-Agent: api-explorer-client

Do I need to insert my own API name in there for the app that I created and has the same API Key?

Здравко
Legendary | Level 20

@Jeff B.63 wrote:

..., my logic app has all the same content with the exception of User-Agent which in the Explorer shows as... Do I need to insert my own API name in there for the app that I created and has the same API Key?


No, you don't need to change it at all. "User-Agent" header doesn't participate in any way to authentication or in endpoints behavior.

Greg-DB
Dropbox Staff

@Jeff B.63 Здравко is correct; while the 'User-Agent' value is meant to contain the app's name, it does not impact the functionality of the API call.

 

If the call is still not working for you, make sure the app is formatting the request correctly. It may help to print out the actual HTTP request, if possible. (If you share that here, be sure to continue to redact the access token though.)

Jeff B.63
Collaborator | Level 8

I am getting the error 

Error in call to API function "sharing/create_shared_link_with_settings": Unexpected URL params: "path"

 

The JSON for that HTTP request was:

{
    "method""POST",
    "queries": {
        "path""D:\\DRYBSMT Dropbox\\Jeff Brown\\~ Pictures - All\\Share Link Testing\\1"
    },
    "headers": {
        "Authorization""*sanitized*",
        "Content-Type""application/json"
    }
}
 
In the Logic Apps HTTP step, the code view looks like this:
 
{
    "inputs": {
        "method""POST",
        "headers": {
            "Authorization""*sanitized*",
            "Content-Type""application/json"
        },
        "queries": {
            "path""D:\\DRYBSMT Dropbox\\Jeff Brown\\~ Pictures - All\\Share Link Testing\\1"
        }
    }
}
The code produced by the API Explorer is:
POST /2/sharing/create_shared_link_with_settings
Host: https://api.dropboxapi.com
User-Agent: api-explorer-client
Authorization: *sanitized*
Content-Type: application/json

{
    "path": "D:\\DRYBSMT Dropbox\\Jeff Brown\\~ Pictures - All\\Share Link Testing\\1"
}

The Logic Apps HTTP data window looks like this:

JeffB63_0-1706112787960.png

 

Finally,  the section of the overall JSON that applies to the request is this:

"HTTP": {
                "inputs": {
                    "headers": {
                        "Authorization""*sanitized*",
                        "Content-Type""application/json"
                    },
                    "method""POST",
                    "queries": {
                        "path""D:\\DRYBSMT Dropbox\\Jeff Brown\\~ Pictures - All\\Share Link Testing\\1"
                    },
                    "uri""https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings"
                },
                "runAfter": {
                    "Compose": [
                        "Succeeded"
                    ]
                },
                "type""Http"
            }
        }

Greg-DB
Dropbox Staff

@Jeff B.63 It looks like you are supplying the "path" parameter as a URL parameter; it instead needs to be supplied in JSON in the request body. You can find more information in the documentation for the /2/sharing/create_shared_link_with_settings endpoint, as well as the documentation for the RPC format it uses.

 

You can also use the API v2 Explorer to see how the call should be constructed. For instance, click "Show Code" and select "View request as" "HTTP request".

 

By the way, your path value doesn't look like a valid Dropbox path. It looks like local Windows file path. I suggest reading the File Access Guide for information on interacting with files on the Dropbox API.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Jeff B.63 Collaborator | Level 8
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?