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
- 123 Developer Announcements
- 54 Articles
- 150 General Questions
- 148 Thrust Services
- 57 OpenText Hackathon
- 37 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 186 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories