14 Replies Latest reply on Nov 21, 2017 11:17 AM by Aqeel Burhani

    Upload local file via REST API

    o.wagner Novice

      Hi all,


      I'm trying to upload a local file via the REST API but I'm not able to get this working. I'm using Javascript/AngularJS and try to Post to the /api/core/v3/contents endpoint. For now, I have something like this:


      var content = {
           "content": {
                "type": "text/html",
                "text": "<body><p>Some interesting text</p></body>"
           "subject": "New Document",
           "type": "file",
           "parent": "baseurl/api/core/v3/places/" + this.placeID
      this.$http.post(url, angular.toJson(content), {
           transformRequest: angular.identity,
           headers: {
                'Content-Type': 'application/json'


      And, as expected, I'm getting an error (400):

        "error" : {
          "code" : "attachmentTooMany",
          "message" : "A single attachment must be specified",
          "status" : 400

      Yeah, because there is no "attachments" in my json, I know. But every example I've found deals with external urls and the documentation https://developers.jivesoftware.com/api/v3/cloud/rest/ContentService.html#createContent(String, String, String, String) also deals with external links.

      Without file, I am able to create for example a document.

      Has anyone ever successfully uploaded a file via the REST API? I think I am missing anything right here... Any suggestions Ryan Rutan ?