cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know all about tools for creatives that work seamlessly with Dropbox, like Adobe? Well, check it out right here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

php curl and data input for standard api curls

php curl and data input for standard api curls

FSUInnovation
Explorer | Level 3

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?

1 Accepted Solution

Accepted Solutions

Re: php curl and data input for standard api curls

Greg-DB
Dropboxer

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.

View solution in original post

3 Replies 3

Re: php curl and data input for standard api curls

Greg-DB
Dropboxer

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.

View solution in original post

Re: php curl and data input for standard api curls

FSUInnovation
Explorer | Level 3

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.

Re: php curl and data input for standard api curls

Greg-DB
Dropboxer

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'.

Poll
Do you work or study in the creative industry? If so, which area?
If you use Adobe, don't forget to check out our latest integrations update here.
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    FSUInnovation Explorer | Level 3
What do Dropbox user levels mean?
Need more support?