Following method works properly to create list view but I am not able to(don't know) add/select columns in that view, in the same REST API call.

Please Help.

({url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('List Name')/views",
type: "POST",
data: "{'__metadata':{'type': 'SP.View'},'ViewType': 'HTML','Title':'view name','PersonalView':false}",            
        "Accept": "application/json;odata=verbose", 
            "Content-Type": "application/json;odata=verbose", 
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            success: function (data, status, xhr) {               
            error: function (xhr, status, error) {

3 Answers 3


In the body/data you have to pass CAML Query like given below on which your view will be created.

"{ '__metadata': { 'type': 'SP.View' }, 'Title': 'View Name', 'PersonalView':   true, 'ViewQuery':'" + query + "'  }";


Create List View using SharePoint REST API.

  • ViewQuery is used to filter the view. I want to specify the set of columns for the view. Mar 19, 2019 at 17:14

you can use addviewfiled in the API URI much like : _api/web/lists(guid)/views(guid)/viewfields/addviewfield('Title')


You can do this using the SP.ViewCollection.add method. Here's some sample code.

  <button type="button" onclick="buttonClickHandler()">Create View</button>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

<script type="text/javascript">
  function buttonClickHandler() {
    var url = _spPageContextInfo.webAbsoluteUrl +

    var data = {
      "parameters": {
        "__metadata": { type: "SP.ViewCreationInformation" },
        "Title": "New View",
        "ViewFields": {
          "__metadata": {
            "type": "Collection(Edm.String)"
          "results": [
        "Query": "<OrderBy><FieldRef Name='ID' /></OrderBy>"

    var call = jQuery.ajax({
      url: url,
      type: "POST",
      headers: {
        "Accept": "application/json;odata=verbose",
        "Content-Type": "application/json;odata=verbose",
        "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
      data: JSON.stringify(data),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.