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

FSUInnovation's avatar
FSUInnovation
Explorer | Level 4
5 years ago

php curl and data input for standard api curls

I know about the authorization and Content Type headers for each curl request I do to the api. But, when I am required to provide data when the require Content Type is application/json, should I include the data in a json encoded array with my http header, or should I reserve this json encoded array for the post fields setopt of the curl?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    There are a few different formats for Dropbox API v2 endpoints, documented here:

    https://www.dropbox.com/developers/documentation/http/documentation#formats

    For example, /2/files/get_metadata uses the "RPC" format, so it requires the parameters as JSON in the request body. Exactly how you set that will depend on your HTTPS client, but for curl in PHP I believe that's done via the 'CURLOPT_POSTFIELDS' option.

    For a different example, the /2/files/download endpoint use the "content-download" format, so it expects the parameters as JSON in the 'Dropbox-API-Arg' request header.

    • FSUInnovation's avatar
      FSUInnovation
      Explorer | Level 4

      So as a general rule of thumb if I am not dealing with a Dropbox-API-Arg or similiar http header requirement the json encoded array or whatever data I would be providing should go to the post fields. I feel that's what you explained above but want to confirm it.

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        Yes, when making an "RPC" style call, you don't use the "Dropbox-API-Arg" header, and your JSON should go in the request body, e.g., as set by 'CURLOPT_POSTFIELDS'.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,915 PostsLatest Activity: 5 hours ago
333 Following

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 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!