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
dragonuber122
5 years agoNew member | Level 2
Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": could not decode input
I'm unable to submit Dropbox API request from YML Gitlab Pipeline using PowerShell (Windows runner). The API requires to pass a JSON as a header parameter and encoding that JSON into YML Gitlab Pipeline doesn't work:
`--header "Dropbox-API-Arg:{\"path\":\"/$BUILD_FILENAME\"}"
The full script step is below as it's now defined in YML:
- C:\Windows\System32\curl.exe -X POST https://content.dropboxapi.com/2/files/upload --header "Authorization:Bearer $DROPBOX_TOKEN" --header "Content-Type:application/octet-stream" --header "Dropbox-API-Arg:{\"path\":\"/$BUILD_FILENAME\"}" --data-binary @$BUILD_FULLFILENAME
The response error is below:
Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": could not decode input as JSONcurl: (3) Port number ended with '\'
I can execute the command above in Windows PowerShell on the same PC where the runner is without any issues:
curl -X POST https://content.dropboxapi.com/2/files/upload --header "Authorization: Bearer XXX" --header "Dropbox-API-Arg: {\"path\": \"/README.md\"}" --header "Content-Type: application/octet-stream" --data-binary @README.md
I don't have the opportunity to debug and monitor the actual HTTP request sent by the pipeline, is it possible to get more details from the dropbox API side to check what is wrong with the request? More details on the error above or the actual content of the request (including headers) would definitely help. How can I encode the JSON properly so it can be executed and pass to the CURL as expected?
The Dropbox API doesn't offer a way to retrieve more detailed error information. It returns the error in the response body, and this particular error just indicates that the supplied value couldn't be parsed as valid JSON. It doesn't offer a way to get more specific information about where the parsing failed within the string though, for example, or a way to echo back the original request data.
As for the issue itself, it seems like you have the right idea here, but looking at the output you shared it appears you're actually getting two different errors. The first is the error message from Dropbox itself about the invalid JSON, but the second seems to be an error message from curl itself, not the Dropbox API, indicating an issue with some curl parameter. (That second one seems similar to this issue, for instance. Since you're not actually supplying a port number though, it may indicate that curl command itself is getting mangled somehow.)
So, it looks like the issue is with how the command is being formatted or escaped, perhaps related to the quotes and variables used in it. We can't provide support for YML Gitlab Pipeline, PowerShell, or curl themselves though, as those are made by third parties.
- Greg-DBDropbox Staff
The Dropbox API doesn't offer a way to retrieve more detailed error information. It returns the error in the response body, and this particular error just indicates that the supplied value couldn't be parsed as valid JSON. It doesn't offer a way to get more specific information about where the parsing failed within the string though, for example, or a way to echo back the original request data.
As for the issue itself, it seems like you have the right idea here, but looking at the output you shared it appears you're actually getting two different errors. The first is the error message from Dropbox itself about the invalid JSON, but the second seems to be an error message from curl itself, not the Dropbox API, indicating an issue with some curl parameter. (That second one seems similar to this issue, for instance. Since you're not actually supplying a port number though, it may indicate that curl command itself is getting mangled somehow.)
So, it looks like the issue is with how the command is being formatted or escaped, perhaps related to the quotes and variables used in it. We can't provide support for YML Gitlab Pipeline, PowerShell, or curl themselves though, as those are made by third parties.
- ingcontiHelpful | Level 5
I got the same, and I am in iOS, IMHO Greg answer is too generic and of no use. we do use DB and we expect to get some TECH answer.
please give us some hints o clues about.
it seems you are not a programmer, either.
- Greg-DBDropbox Staff
ingconti Thanks for the feedback! While we're not able to provide support for using third party platforms, we're happy to help however we can with the Dropbox API itself. If you have any specific question or issue regarding the Dropbox API, please feel free to share the details so we can take a look.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,910 PostsLatest Activity: 3 days 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!