How to upload file in Content Server (OTCS) using REST API and C#
static string createDocument(string authToken, string type, string parent_id, string name, string description, string file)
{
var client = new RestClient("http://localhost/otcs/cs.exe/");
var request = new RestRequest("api/v1/nodes", Method.POST);
request.AddHeader("OTCSTICKET", authToken);
request.AddParameter("type", type);
request.AddParameter("parent_id", parent_id);
request.AddParameter("name", name);
request.AddParameter("description", description);
request.AddFile("file", file);
var content = JObject.Parse(client.Execute(request).Content);
return content["id"].ToString();
}
Comments
-
Hi All,
Found Solution !!! :D
I am able to upload a file using below code in C#.
C# Code:
static string createDocument(string authToken, string type, string parent_id, string name, string description, string file)
{
var client = new RestClient("http://localhost/otcs/cs.exe/");
var request = new RestRequest("api/v1/nodes", Method.POST);
request.AddHeader("OTCSTICKET", authToken);
request.AddParameter("type", type);
request.AddParameter("parent_id", parent_id);
request.AddParameter("name", name);
request.AddParameter("description", description);
request.AddFile("file", file);
var content = JObject.Parse(client.Execute(request).Content);
return content.ToString();
}
Moreover while calling the method we need to provide complete path of a file in given format. Below is the sample request.
createDocument(authToken, "144", "2000", "File1", "File1", "C:\\Users\\Administrator\\Desktop\\Sample Document.txt")
0
Categories
- All Categories
- 122 Developer Announcements
- 53 Articles
- 151 General Questions
- 146 Thrust Services
- 56 OpenText Hackathon
- 35 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 917 Cloud Fax and Notifications
- 83 Digital Asset Management
- 9.4K Documentum
- 31 eDOCS
- 178 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 9 XM Fax
- Follow Categories