cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

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

dragonuber122
New member | Level 2
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution

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

3 Replies 3

Greg-DB
Dropbox Staff
Go to solution

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.

ingconti
Helpful | Level 5
Go to solution

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-DB
Dropbox Staff
Go to solution

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

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    ingconti Helpful | Level 5
What do Dropbox user levels mean?