cURL with HubSpot API for moving files


#1

Hello,

I have been trying to use cURL (on windows) to move files from one area to another while renaming the file from the documentation here: http://developers.hubspot.com/docs/methods/files/post_files_file_id_move_file

This is the command I am using and it is not working. Any help would be appreciated (i’ve removed the api key and ids for personal purposes and replace with nines for folder and eights for file id ):

curl -v -H "Accept: application/json" -X POST -d {"folder_id":"9999999","name":"file_new_name"} http://api.hubapi.com/filemanager/api/v2/files/8888888?hapikey=034895490random-3934key

This is the response I am getting:

Note: Unnecessary use of -X or --request, POST is already inferred.

  • Trying 23.193.235.148…
  • Connected to api.hubapi.com (23.193.235.148) port 80 (#0)

POST /filemanager/api/v2/files/99999999?hapikey=jldasljkadsjlkadsjklasdjkl HTTP/1.1
Host: api.hubapi.com
User-Agent: curl/7.46.0
Accept: application/json
Content-Length: 59
Content-Type: application/x-www-form-urlencoded

  • upload completely sent off: 59 out of 59 bytes
    < HTTP/1.1 415 Unsupported Media Type
    < Access-Control-Allow-Credentials: false
    < Content-Length: 0
    < Date: Tue, 30 Aug 2016 23:37:56 GMT
    < Connection: close
    <
  • Closing connection 0

#2

Hi @ajlaporte

The example linked on that page has the wrong URL, it needs to include /move-file at the end. Also, you’ll need to include the content-type: application/json header in your request (the -d option defaults to application/x-www-form-urlencoded), and you may need to escape the JSON data as well:

curl -v -H "Content-Type: application/json" -X POST -d "{\"folder_id\":\"9999999\",\"name\":\"file_new_name\"}" http://api.hubapi.com/filemanager/api/v2/files/8888888/move-file?hapikey=034895490random-3934key

I’ll get the documentation page updated with the correct example URL.


#3

Thank You David. Makes sense why this wasn’t working even when trying the content type.

-AJ