Guest User

Untitled

a guest
Jan 16th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. let reqHeaders = new Headers({ 'Content-Type': undefined});
  2. reqHeaders.append('Accept', 'application/vnd.emc.documentum+json');
  3. //setting username
  4. let username = "<username>";
  5. //setting password
  6.  
  7. let password = "<password>";
  8. //creating converting to binary
  9. let authToken = btoa(username + ":" +password);
  10. //setting up the Authorization
  11. reqHeaders.append('Authorization', 'Basic ' + authToken);
  12.  
  13. //-Creating the format in the documentum way for the metadata.
  14.  
  15. var docObj = this.buildPersistentObject(['r_object_type', 'dm_document', 'object_name', "test.pdf"])
  16.  
  17. //enter code here`Forming Multipart/Form -->
  18.  
  19. var fd = new FormData();
  20. fd.append('data', new Blob([JSON.parse(JSON.stringify(docObj))], {type: 'application/vnd.emc.documentum+json'}));
  21. fd.append('content', file);
  22.  
  23. <!-- Sending the Post Request -->
  24.  
  25. return this._http.post("http://localhost:8080/dctm-rest/repositories/demo/folders/0b01e24080008993/documents", fd, { headers: reqHeaders });
  26.  
  27. <!-- Below is the error i am getting when i post the request. But i have not set application/octet-stream sending only
  28.  
  29. {"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"}
  30.  
  31. <!-- Creating Mulitpart Message -->
  32. var fd = new FormData()
  33. <!-- appending the metadata -->
  34. fd.append('metadata', new Blob([angular.toJson(data)], {type: dctmConstants.MIME.VND_DCTM_JSON}))
  35. <!-- appending the content -->
  36. fd.append('content', file)
  37. <!-- setting the content type to undefined -->
  38. headers[dctmConstants.HEADERS.CONTENT_TYPE] = undefined;
  39.  
  40. // How this can be converted to angular 5
  41.  
  42. headers['transformRequest'] = angular.identity;
  43. data = fd
  44.  
  45. <!-- Post Request call -->
  46.  
  47. 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