Example #1
0
        public ApiResponse <ContentPropertyResponse> CreateContentlessDocumentWithHttpInfo(string repo, string folderId, ContentProperty contentProperty = null)
        {
            // verify the required parameter 'accountId' is set
            if (repo == null)
            {
                throw new ApiException(400, "Missing required envelope custom field parameter 'documentum repository' when calling DocumentumService->uploadDocument");
            }
            // verify the required parameter 'documentId' is set
            if (folderId == null)
            {
                throw new ApiException(400, "Missing required envelope custom field parameter 'folder' when calling DocumentumService->uploadDocument");
            }

            var    localVarPath         = "/folders/{folderId}/documents".Replace("{folderId}", folderId);
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.Default.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/vnd.emc.documentum+json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // localVarHttpContentType = "application/vnd.emc.documentum+json";

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/vnd.emc.documentum+json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                if (localVarHttpContentType.Contains("Accept"))
                {
                    localVarHeaderParams.Remove("Accept");
                }
            }
            localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);

            if (localVarHttpContentType != null)
            {
                /*if (localVarHttpContentType.Contains("Content-Type"))
                 * {
                 *  localVarHeaderParams.Remove("Content-Type");
                 * }
                 * localVarHeaderParams.Add("Content-Type", localVarHttpContentType);*/
                // set "format" to json by default
                // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
                //localVarPathParams.Add("format", "json");

                if (contentProperty != null && contentProperty.GetType() != typeof(byte[]))
                {
                    localVarPostBody = Configuration.ApiClient.Serialize(contentProperty); // http body (model) parameter
                }
                else
                {
                    localVarPostBody = contentProperty; // byte array
                }
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("CreateContentless", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }


            // DocuSign: Handle for PDF return types
            if (localVarResponse.ContentType != null && !localVarResponse.ContentType.ToLower().Contains("json"))
            {
                return(new ApiResponse <ContentPropertyResponse>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (ContentPropertyResponse)Configuration.ApiClient.Deserialize(localVarResponse.RawBytes, typeof(ContentPropertyResponse))));
            }
            else
            {
                return(new ApiResponse <ContentPropertyResponse>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (ContentPropertyResponse)Configuration.ApiClient.Deserialize(localVarResponse, typeof(ContentPropertyResponse))));
            }
        }