cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

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: 

Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": could not decode input

Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": could not decode input

New member | Level 2

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?

1 Accepted Solution

Accepted Solutions
Highlighted

Re: Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg":

Dropboxer

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.

View solution in original post

1 Reply 1
Highlighted

Re: Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg":

Dropboxer

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.

View solution in original post

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?