public static ContentPropertyResponse CreateContentlessDocumentLinkToFolder(string repo, string folderId) { DocumentumServiceUtils.ConfigureApiClient(repo); ContentProperty contentProperty = new ContentProperty(); contentProperty.properties = new PropertiesType(); contentProperty.properties.r_object_type = "dwr_gen_doc"; contentProperty.properties.object_name = "readme6"; contentProperty.properties.author_creator = "Pedro Barroso"; contentProperty.properties.author_date = "2017-09-26"; contentProperty.properties.topic_subject = "The subject"; IDocumentumApi documentumApi = new DocumentumApi(); ContentPropertyResponse response = null; try { response = documentumApi.CreateContentlessDocument(repo, folderId, contentProperty); } catch (ApiException ex) { Log.Error(ex); } return(response); }
// POST api/connect //[ResponseType(typeof{string})] public HttpResponseMessage Post([FromBody] DocuSignEnvelopeInformation dsEnvInfo) { var dsEnv = ServiceUtil.buildEnvironment(dsEnvInfo); Log.Info("Processing envelopeId " + dsEnvInfo.EnvelopeStatus.EnvelopeID); Log.Info("Creating HangFire backgoundJob "); IDictionary <string, string> localECF = DocumentumServiceUtils.getDocumentProperties(dsEnvInfo); var jobId = Hangfire.BackgroundJob.Enqueue(() => DocumentumUploadTask.uploadDocument(localECF, dsEnvInfo.EnvelopeStatus.EnvelopeID, "combined", DocumentOptions.Combined_No_Cert)); Log.Info("Hangfire JobId created: " + jobId); ConnectProcessResponse response = new ConnectProcessResponse(dsEnvInfo.EnvelopeStatus.EnvelopeID, jobId); Log.Info("Reply HTTP 200 to DocuSign JobId created: " + jobId); return(this.Request.CreateResponse <string>(HttpStatusCode.OK, dsEnvInfo.EnvelopeStatus.EnvelopeID + " : " + jobId)); }
public void UploadDocsWithProperties2(string repo, string folderId, byte[] documentBytes, string fileName, ContentProperty contentProperty = null) { var request = new RestRequest("/" + repo + "/folders/" + folderId + "/documents", Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(contentProperty); request.AddFileBytes("content", documentBytes, fileName, "application/pdf"); /* RestResponse<bool> * request.AddParameter("object[name]", "object"); * request.AddParameter("object[tag_number]", tagnr); * request.AddParameter("machine[serial_number]", machinenr); * request.AddParameter("machine[safe_token]", safe_token); * request.AddFile("receipt[receipt_file]", File.ReadAllBytes(path), "Invoice.pdf", "application/octet-stream"); */ request.AddHeader("Authorization", DocumentumServiceUtils.CreateBasicBearToken()); RestClient restClient = new RestClient( System.Configuration.ConfigurationManager.AppSettings["documentumUrl"].Replace("{REPO}", repo)); var response = restClient.Execute(request); Log.Info("Called documentum with response: " + response); }
public void UploadDocsWithProperties(IDictionary <string, string> ecf, byte[] documentBytes) { // let's check that all my envelope custom fields are not null foreach (KeyValuePair <string, string> entry in ecf) { if (entry.Value == null) { throw new ApiException(400, "Missing required envelope custom field parameter " + entry.Key + " when calling DocumentumService->uploadDocument"); } } var documentumApi = new DocumentumApi(); ContentProperty contentProperty = new ContentProperty(); contentProperty.properties = new PropertiesType(); contentProperty.properties.r_object_type = ecf[EnvelopeMetaFields.DocumentType]; contentProperty.properties.object_name = ecf[EnvelopeMetaFields.PolicyNumber] + "-" + ecf[EnvelopeMetaFields.FormID]; contentProperty.properties.author_creator = ecf[EnvelopeMetaFields.AuthorCreator]; contentProperty.properties.author_date = ecf[EnvelopeMetaFields.AuthoredDate]; contentProperty.properties.subject = ecf[EnvelopeMetaFields.Subject]; contentProperty.properties.topic_subject = ecf[EnvelopeMetaFields.FormID] + "-" + ecf[EnvelopeMetaFields.FormDescription]; contentProperty.properties.business_record = ecf[EnvelopeMetaFields.BusinessRecord]; string requestHost = System.Configuration.ConfigurationManager.AppSettings["documentumUrl"].Replace("{REPO}", ecf[EnvelopeMetaFields.Repository]); var localVarPath = "/folders/{folderId}/documents?overwrite=true".Replace("{folderId}", ecf[EnvelopeMetaFields.FolderId]); // Create a http request to the server endpoint that will pick up the // file and file description. HttpWebRequest requestToServerEndpoint = (HttpWebRequest)WebRequest.Create(requestHost + localVarPath); string boundaryString = "FFF3F395A90B452BB8BEDC878DDBD152"; // Set the http request header requestToServerEndpoint.Method = WebRequestMethods.Http.Post; requestToServerEndpoint.ContentType = "multipart/form-data; boundary=" + boundaryString; requestToServerEndpoint.KeepAlive = true; requestToServerEndpoint.Headers.Add("Authorization", "Basic " + DocumentumServiceUtils.CreateBasicBearToken()); requestToServerEndpoint.Accept = "application/vnd.emc.documentum+json"; // Use a MemoryStream to form the post data request, // so that we can get the content-length attribute. MemoryStream postDataStream = new MemoryStream(); StreamWriter postDataWriter = new StreamWriter(postDataStream); // Include value from the tag_number text area in the post data postDataWriter.Write("\r\n--" + boundaryString + "\r\n"); postDataWriter.Write("Content-Disposition: form-data; name=\"object\"\r\n"); postDataWriter.Write("Content-Type: application/vnd.emc.documentum+json;charset=UTF-8\r\n\r\n"); postDataWriter.Write(JsonConvert.SerializeObject(contentProperty)); // Include the file in the post data postDataWriter.Write("\r\n--" + boundaryString + "\r\n"); postDataWriter.Write("Content-Disposition: form-data; name=\"content\"\r\n"); postDataWriter.Write("Content-Type: application/pdf\r\n\r\n"); postDataWriter.Flush(); postDataStream.Write(documentBytes, 0, documentBytes.Length); postDataWriter.Write("\r\n--" + boundaryString + "--\r\n"); postDataWriter.Flush(); // Set the http request body content length requestToServerEndpoint.ContentLength = postDataStream.Length; // Dump the post data from the memory stream to the request stream Stream s = requestToServerEndpoint.GetRequestStream(); postDataStream.WriteTo(s); postDataStream.Close(); s.Close(); try { var response = requestToServerEndpoint.GetResponse(); Log.Info("Called documentum with response: " + response); } catch (WebException ex) { using (var stream = ex.Response.GetResponseStream()) using (var reader = new StreamReader(stream)) { throw new ApiException((int)GetHttpStatusCode(ex), "Error calling DocumentumApi=>UploadDocsWithProperties ", reader.ReadToEnd()); } } }