"status":415,"code":"E_UNSUPPORTED_MEDIA_TYPE","message":"The specified media type application/octet

Hi,

I am trying to create a content using Angular 6 but unable to do so. I am using the below URL.
http://localhost:8080/dctm-rest/repositories/demo/folders/0b01e24080008993/documents

I am able to do in RestClient using Java but not in Angular 6 and receiving the below error.

Attached is the image of the request and response and the error message.

If you have any code related to upload in Angular 2.x or Angular 5/6 please let me know how to upload

Thanks
vinod.

Vinod Krishna
Architect, Consulting Services
OpenText

Comments

  • What's your payload and what's the content type? As explained in the error message, it must be application/vnd.emc.documentum+json.

  • content type should be Multiform/data and there is some issue in mentioning content-type = 'multipform/data' so we are mentioning it as undefined.
    payload I am setting metadata and content in FormData.

    Vinod Krishna
    Architect, Consulting Services
    OpenText

  • As explained in the Documentum REST Reference Guide (page 297 and following - "Import SysObject Metadata and Contents"), the payload must be multipart/form-data or multipart/mixed. Metadata part must be
    Content-Disposition: form-data; name=metadata
    Content-Type: application/vnd.emc.documentum+xml

    and content part must be
    Content-Disposition: form-data; name=binary
    Content-Type: <actual content type, e.g application/pdf)

  • In Angular JS, Below configurations will create a mulitpart form.

    const httpOptions = {
    headers: new HttpHeaders({
    'Accept': 'application/vnd.emc.documentum+json',
    'Authorization': 'Basic ' + authToken,

            })
          };
    

    var fd = new FormData();
    fd.append('data', JSON.stringify(docObj));
    fd.append('content', body)
    return this.http.post("http://localhost:8080/dctm-rest/repositories/demo/folders/0b01e24080008993/objects?format=pdf", fd, httpOptions); //working

    Vinod Krishna
    Architect, Consulting Services
    OpenText