Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let reqHeaders = new Headers({ 'Content-Type': undefined});
- reqHeaders.append('Accept', 'application/vnd.emc.documentum+json');
- //setting username
- let username = "<username>";
- //setting password
- let password = "<password>";
- //creating converting to binary
- let authToken = btoa(username + ":" +password);
- //setting up the Authorization
- reqHeaders.append('Authorization', 'Basic ' + authToken);
- //-Creating the format in the documentum way for the metadata.
- var docObj = this.buildPersistentObject(['r_object_type', 'dm_document', 'object_name', "test.pdf"])
- //enter code here`Forming Multipart/Form -->
- var fd = new FormData();
- fd.append('data', new Blob([JSON.parse(JSON.stringify(docObj))], {type: 'application/vnd.emc.documentum+json'}));
- fd.append('content', file);
- <!-- Sending the Post Request -->
- return this._http.post("http://localhost:8080/dctm-rest/repositories/demo/folders/0b01e24080008993/documents", fd, { headers: reqHeaders });
- <!-- Below is the error i am getting when i post the request. But i have not set application/octet-stream sending only
- {"status":415,"code":"E_UNSUPPORTED_MEDIA_TYPE","message":"The specified media type application/octet-stream is not supported. Supported media types: [application/vnd.emc.documentum+json, application/vnd.emc.documentum+xml].","details":"Content type 'application/octet-stream' not supported","id":"adcf72a5-f43e-4fa6-8cee-54db707122d2"}
- <!-- Creating Mulitpart Message -->
- var fd = new FormData()
- <!-- appending the metadata -->
- fd.append('metadata', new Blob([angular.toJson(data)], {type: dctmConstants.MIME.VND_DCTM_JSON}))
- <!-- appending the content -->
- fd.append('content', file)
- <!-- setting the content type to undefined -->
- headers[dctmConstants.HEADERS.CONTENT_TYPE] = undefined;
- // How this can be converted to angular 5
- headers['transformRequest'] = angular.identity;
- data = fd
- <!-- Post Request call -->
- return this.http({method: 'POST',url: "http://localhost:8080/dctm-rest/repositories/demo/folders/0b01e24080008993/documents",headers: headers,data: data})
Add Comment
Please, Sign In to add comment