You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Borrow
3 months agoExplorer | Level 3
"Couldn't resolve host name" error
I made app with visual studio 2015 and used libcurl.
but this shows error "Couldn't resolve host name"
CURL *curl;
CURLcode res;
std::string readBuffer;
// Your Dropbox access token
std::string accessToken = "****";
// File to upload
std::string filePath = "D://test.txt";
std::string fileName = "file.txt"; // Name of the file as it will appear in Dropbox
// Open the file
std::ifstream file(filePath, std::ios::binary | std::ios::ate);
if (!file.is_open()) {
std::cerr << "Failed to open file." << std::endl;
return 1;
}
// Get file size
std::size_t fileSize = file.tellg();
file.seekg(0, std::ios::beg);
// Read the file into a buffer
char* fileBuffer = new char[fileSize];
file.read(fileBuffer, fileSize);
file.close();
// Set up the API request
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) {
std::string url = "https://content.dropboxapi.com/2/files/upload";
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, ("Authorization: Bearer " + accessToken).c_str());
headers = curl_slist_append(headers, "Content-Type: application/octet-stream");
// Dropbox API specifics
std::string dropboxApiArg = "{\"path\":\"/" + fileName + "\",\"mode\":\"add\",\"autorename\":true,\"mute\":false}";
headers = curl_slist_append(headers, ("Dropbox-API-Arg: " + dropboxApiArg).c_str());
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fileBuffer);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, fileSize);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
std::cerr << "cURL error: " << curl_easy_strerror(res) << std::endl;
}
else {
std::cout << "File uploaded successfully." << std::endl;
}
// Cleanup
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
delete[] fileBuffer;
}
curl_global_cleanup();
return 0;
please help me
- DB-DesDropbox Engineer
Hi Borrow,
The "couldn't resolve hostname" error typically indicates an issue with DNS resolution rather than a problem with our API.
To troubleshoot this in your application, we would recommend verifying that the hostname is correctly specified in your code and checking the use of other functions. Additionally, ensure your network settings allow DNS queries and that there are no underlying connectivity issues.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,912 PostsLatest Activity: 2 hours agoIf 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 or Facebook.
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!