Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

raysharp's avatar
raysharp
Explorer | Level 3
8 years ago

https://api.dropboxapi.com/2/users/get_space_usage no response

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.

10 Replies

  • raysharp's avatar
    raysharp
    Explorer | Level 3
    8 years ago

    * 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.1
    Host: api.dropboxapi.com
    Accept: */*
    Authorization: Bearer <ACCESS_TOKEN>

     

     

    we are waiting for a long time . but no response from the dropbox server

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago
    I just tried this, and it is working properly for me. Are you still seeing this issue? If so, is there anything on your network connection, such as a firewall or proxy, that may be interfering?

    By the way, I redacted it from your post, but for the sake of security, you should disable that access token. You can do so by revoking access to the app entirely, if the access token is for your account, here:

    https://www.dropbox.com/account/connected_apps

    Or, you can disable just this access token using the API:

    https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke
  • raysharp's avatar
    raysharp
    Explorer | Level 3
    8 years ago

    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.1
    Host: api.dropbox.com
    Accept: */*
    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 0
    curl_easy_perform() failed: Failed writing received data to disk/application

    err 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.1
    Host: api.dropboxapi.com
    Accept: */*
    Authorization: Bearer XXXXXXXXXXXXXXXX

     

     

     

    and there is no response from the dropbox.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    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! 

  • raysharp's avatar
    raysharp
    Explorer | Level 3
    8 years ago

    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
    https://api.dropboxapi.com/2/users/get_space_usage

    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.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago
    Thanks for the additional information. Since this is affecting all accounts, and the same endpoint works when using curl directly on the command line, it sounds like this is specific to how it's being called in your script using the curl lib API.

    Can you share that script that has the issue so we can use it to reproduce the issue here? Thanks!
  • raysharp's avatar
    raysharp
    Explorer | Level 3
    8 years ago

     

    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.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago

    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");

     

  • blink's avatar
    blink
    Explorer | Level 3
    8 years ago

    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);

About Dropbox API Support & Feedback

Node avatar for 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!