Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
milesmajefski
8 years agoNew member | Level 2
Accessing get_metadata endpoint without Dropbox Javascript package
For fun, I'm making a cataloging web app using asp.net core 2.1 MVC and javascript. I don't need a frontend framework, so I don't want to bring in the whole NodeJS npm situation into this project. ...
- 8 years ago
While we recommend using the official libraries, it's not required. You can always call the Dropbox API HTTPS endpoints directly if you prefer. The documentation covers the requirements for each endpoint, and includes an example of calling using curl, e.g., for /2/files/get_metadata.
It looks like you're running in to a CORS issue though, due to your use of `credentials: 'include'`. Dropbox API calls, such as for /2/files/get_metadata, are authenticated using Dropbox API access tokens, not the browser's credentials. You need to supply the access token in the "Authorization" header as a "Bearer" token. (Also, the parameters should be a JSON string in the body.)
So, you code should look more like this:
fetch(apiURL, { method: 'post', headers: { "Authorization": "Bearer ACCESS_TOKEN_HERE", "Content-type": "application/json; charset=UTF-8" }, body: JSON.stringify(reqData), })
Greg-DB
Dropbox Community Moderator
8 years agoWhile we recommend using the official libraries, it's not required. You can always call the Dropbox API HTTPS endpoints directly if you prefer. The documentation covers the requirements for each endpoint, and includes an example of calling using curl, e.g., for /2/files/get_metadata.
It looks like you're running in to a CORS issue though, due to your use of `credentials: 'include'`. Dropbox API calls, such as for /2/files/get_metadata, are authenticated using Dropbox API access tokens, not the browser's credentials. You need to supply the access token in the "Authorization" header as a "Bearer" token. (Also, the parameters should be a JSON string in the body.)
So, you code should look more like this:
fetch(apiURL, {
method: 'post',
headers: {
"Authorization": "Bearer ACCESS_TOKEN_HERE",
"Content-type": "application/json; charset=UTF-8"
},
body: JSON.stringify(reqData),
})milesmajefski
8 years agoNew member | Level 2
Thank You! I see that when I make the body parameter a string and make the other changes concerning Authorization, it works. However I am using the the Access Token that I made manually for my own development purposes. My new problem is about getting the access token on the server side. I'll post another question after I have thought about everything some more. :slight_smile:
- Greg-DB8 years ago
Dropbox Community Moderator
Great! I'm glad to hear you were able to get that working.
For information on the OAuth app authorization flow, I recommend reviewing the OAuth guide and the authorization documentation.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!