public static FileUpload UploadFile(string ticket, string groupId, string folderId, string fileId, string fileName, string filePath, bool saveAsNewVersion) { if (string.IsNullOrWhiteSpace(ticket)) { throw new ArgumentNullException("ticket"); } if (string.IsNullOrWhiteSpace(groupId)) { throw new ArgumentNullException("groupId"); } if (string.IsNullOrWhiteSpace(folderId)) { throw new ArgumentNullException("folderId"); } if (string.IsNullOrWhiteSpace(fileName)) { throw new ArgumentNullException("fileName"); } if (string.IsNullOrWhiteSpace(filePath)) { throw new ArgumentNullException("filePath"); } var requestParams = new Dictionary <string, string>(); requestParams.Add("ticket", ticket); requestParams.Add("groupId", groupId); requestParams.Add("folderId", folderId); requestParams.Add("versionId", fileId); requestParams.Add("filename", fileName); requestParams.Add("newVersion", saveAsNewVersion.ToString()); var fileInfo = new FileInfo(filePath); if (IsFileLocked(fileInfo)) { throw new ArgumentException("fileInfo"); } var restServiceUrl = ConfigurationManager.GetValue(Resources.RestServiceUrlKey); var response = new RestServiceAgent().SendPostRequest(string.Format("{0}/{1}", restServiceUrl, "fileUpload"), requestParams, fileInfo, "file"); //Deserialize json response var jsonReader = new JsonTextReader(new StringReader(response)); var jObject = JObject.Load(jsonReader); var jsonSerializer = new JsonSerializer(); var fileUploadResponse = (FileUploadResponse)jsonSerializer.Deserialize(new JTokenReader(jObject), typeof(FileUploadResponse)); if (fileUploadResponse.res == "ok") { var fileUpload = new FileUpload() { nodeId = fileUploadResponse.nodeId, modifiedTime = fileUploadResponse.modifiedTime }; return(fileUpload); } else { throw new RestResponseException(fileUploadResponse.errorDesc); } }