Hello. we use Dropbox HTTP V2 API to upload files . all it's ok.
but. there is no response when send
https://api.dropboxapi.com/2/users/get_space_usage
post .
we don't know why.
* About to connect() to api.dropboxapi.com port 443 (#1)* Trying 162.125.7.7...* Connected to api.dropboxapi.com (162.125.7.7) port 443 (#1)* CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384* Server certificate:* subject: CN=api.dropboxapi.com,OU=Dropbox Ops,O="Dropbox, Inc",L=San Francisco,ST=California,C=US* start date: Feb 07 00:00:00 2017 GMT* expire date: Feb 12 12:00:00 2020 GMT* common name: api.dropboxapi.com* issuer: CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US> POST /2/users/get_space_usage HTTP/1.1Host: api.dropboxapi.comAccept: */*Authorization: Bearer <ACCESS_TOKEN>
we are waiting for a long time . but no response from the dropbox server
Thank you for your prompt reply!
1. the network does not matter.
2. The access token I post is not correct, so it's security.
I show the entire process.
[root@iZu1hoqybaaZ new]# ./drop* About to connect() to api.dropbox.com port 443 (#0)* Trying 162.125.7.7...* Connected to api.dropbox.com (162.125.7.7) port 443 (#0)* Initializing NSS with certpath: sql:/etc/pki/nssdb* CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384* Server certificate:* subject: CN=api.dropboxapi.com,OU=Dropbox Ops,O="Dropbox, Inc",L=San Francisco,ST=California,C=US* start date: Feb 07 00:00:00 2017 GMT* expire date: Feb 12 12:00:00 2020 GMT* common name: api.dropboxapi.com* issuer: CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US> GET /1/oauth/request_token HTTP/1.1Host: api.dropbox.comAccept: */*Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="XXXXX", oauth_signature="XXXXXXXX&"< HTTP/1.1 200 OK< Server: nginx< Date: Wed, 07 Feb 2018 09:18:12 GMT< Content-Type: application/x-www-form-urlencoded< Transfer-Encoding: chunked< Connection: keep-alive< Cache-Control: no-cache< Pragma: no-cache< X-Content-Type-Options: nosniff< X-Dropbox-Request-Id: 39d92ec6ee1a74da459f4e804ab11d60< X-Frame-Options: SAMEORIGIN< X-Server-Response-Time: 83<* Failed writing body (0 != 64)* Failed writing data* Closing connection 0curl_easy_perform() failed: Failed writing received data to disk/applicationerr code httpcode == 200* About to connect() to api.dropboxapi.com port 443 (#1)* Trying 162.125.7.7...* Connected to api.dropboxapi.com (162.125.7.7) port 443 (#1)* CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384* Server certificate:* subject: CN=api.dropboxapi.com,OU=Dropbox Ops,O="Dropbox, Inc",L=San Francisco,ST=California,C=US* start date: Feb 07 00:00:00 2017 GMT* expire date: Feb 12 12:00:00 2020 GMT* common name: api.dropboxapi.com* issuer: CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US> POST /2/users/get_space_usage HTTP/1.1Host: api.dropboxapi.comAccept: */*Authorization: Bearer XXXXXXXXXXXXXXXX
and there is no response from the dropbox.
Are you seeing this for all accounts, or does this only seem to affect specific account(s)? If it's only affecting specific ones, please open an API ticket and share the account IDs for reference. Also, does the call eventually time out, and if so, what output do you get? Thanks in advance!
Thank you for your prompt reply.
It's not affect specific account(s) but for all accounts.
we use the same access token by
curl -X POST https://api.dropboxapi.com/2/users/get_space_usage --header "Authorization: Bearer <access token>
The dropbox server return right result.and we use upload API
https://content.dropboxapi.com/2/files/upload
The dropbox server return 200 ok.but only use API
The dropbox server have no reponse.
we wait for a long long time . there is nothing output .
PS. we use curl lib API send post.
static const char *DROPBOX_GET_CAPITY = "https://api.dropboxapi.com/2/users/get_space_usage";
static int dropbox_get_capity(const char *access_token){ char buffer[BUFF_SIZE] = {0}; long httpCode = 0; CURLcode res; if(!access_token) return -1; if (curl) { struct curl_slist *headers = NULL; /* init to NULL is important */ snprintf(buffer, sizeof(buffer), "Authorization: Bearer %s", access_token); headers = curl_slist_append(headers, buffer); headers = curl_slist_append(headers, "Content-Type: "); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_URL, DROPBOX_GET_CAPITY); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, get_capity_cb); curl_easy_setopt(curl, CURLOPT_POST, 1L); /* Perform the request, res will get the return code */ curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L); // thread safe requirement curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); res = curl_easy_perform(curl); // will block here!!! /* Check for errors */ if(res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); printf(" \nerr code httpcode == %ld \n", httpCode); } if (res == CURLE_OK) { curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); printf(" \nhttpcode == %ld \n", httpCode); } curl_slist_free_all(headers); } return (int)httpCode;}
if you need more code . I will share it. Thanks.
Hi , @10
Any good news ?
Thanks! That's helpful. It looks like curl is waiting for the request body. Since this API call doesn't require one, you need to tell curl that, like this:
curl_easy_setopt(curl, CURLOPT_POST, 1L);curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0);
Or, you can send the JSON "null" in the body instead:
headers = curl_slist_append(headers, "Content-Type: application/json");curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "null");
Many Thanks!
It's all ok now!
we add two lines code
headers = curl_slist_append(headers, "Content-Type: ");
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0);