Save Content - Legacy

Last Updated: Jul 27, 2021
documentation for the dotCMS Content Management System
Deprecated

Note:

The Content API has been deprecated. New applications should use the [Workflow REST API](workflow-rest-api), and existing applications using the Content API should migrate to using the Workflow API as soon as practical.

Support for posting content using the Content API may be removed in a future release.


Here is an example of a form that will perform a simple post and simple redirect upon posting the content.


<script type="text/javascript" >
     
    $(document).ready(function() {
     
    $("#webup").submit(function(e) {
    e.preventDefault();
   
      var dataObj= {
      'title': $('#title').val(),
      'body': $('#body').val(),
      'contentHost': 'demo.dotcms.com',
      'stName': 'webPageContent'
      };
     
      $.ajax({
          url: '/api/content/save/1',
          type: 'POST',
          cache: false,
          data: dataObj,
          beforeSend: function (request){

          request.setRequestHeader("DOTAUTH", window.btoa("admin@dotcms.com:admin"));
        },
   
        success: function(data,status,xhr) {
          window.location = "http://dotcms.com";
        },
        error: function(data,status,xhr) {
          alert("fail: " + data);
          console.log(data);
        },
          });
      });
    });
</script>
     
<form id="webup">
     
    <div class="form-group">
    <label for="title" class="required">Title</label>
    <input type="text" class="form-control" id="title" name="title" value="Here is a title">
    </div>
     
    <div class="form-group">
    <label for="body" class="required">Body</label>
    <textarea id="body" name="body" >Here is some texttest</textarea>
    </div>
     
    <br>&nbsp;<br>&nbsp;
    <div class="form-group">
      <input type="submit" value="Give 'er a go" />
    </div>
     
</form>

On this page

×

We Dig Feedback

Selected excerpt:

×