Status: Open
Status: Answered
Status: Closed
Status: Duplicate

REST API: How can i download a document?

0
Posted Nov 11 by Me Ra.

I've looked through the guide for the REST API (Content Server API v1), I did not see an option to download a file. Could someone point me to how I can use the REST API to download a file?

5 Answers

0
BEST ANSWER: As chosen by the author.

Have a look at /nodes/{id}/content, please.


0
BEST ANSWER: As chosen by the author.

Just to expound on Ferdinandi's answer: I had the same challenge. My project is a ColdFusion solution that integrates with Content Server. Here is the call I use to grab a file from our Content Server and download it to our ColdFusion server.

The reference above says to use "/nodes/{id}/content/{filename}" with both id and filename as required inputs. It seemed odd to provide the filename as an input parameter, but whatever it works…most of the time. I found that if the filename has spaces, the call fails. However, if you remove the filename from the URL call, it still works…at least so far. The filename is still needed, but as a cfhttp parameter.

Prior to using the code below, I have a cfhttp call that logs into CS and a second that gets the details of the node (which includes the filename). I can share those as well, if needed.

<cfhttp method="GET"
    url="http://{your cs server}/livelink/api/v1/nodes/#cs_node_id#/content"
    file="#new_local_filename#"
    path="#drive_and_path#"
    result="downloadInfo">
    <cfhttpparam type="header" name="OTCSTICKET" value="#cookie.TICKET#">
</cfhttp>

0
BEST ANSWER: As chosen by the author.

About the {filename} path parameter:

This parameter is optional; the documentation is wrong. If there is one more path element after the /content in the URL, the server ignores it, assuming that it is a file name.

If you write a server-to-server application, you do not need to provide the filename. This parameter is used by the CS UI Widgets and can be used by web-browser UIs, which support file download using the REST API. This parameter was added to offer more convenient file download - the File-Save-As dialog should offer a real file name to the user. The browser should parse the file name from the Content-Disposition response header for that. However, some IE versions ignored the header and offered the last part of the URL path as the file name. Appending an unused file name at the end of the path was a workaround for this problem.


0
BEST ANSWER: As chosen by the author.

I tried the command "/nodes/{id}/content", then what? How do I save the file with javascript?


0
BEST ANSWER: As chosen by the author.

Ok I got it!!

jQuery ajax is not able to handle binary responses properly (can't set responseType),
so it's better to use a plain XMLHttpRequest call


 You have subscribed and will receive email notifications of updates to this topic. To unsubscribe, uncheck the checkbox.

Statistics

Related categories

Related tags

Your answer

To leave an answer, please sign in.