Saturday, June 18, 2016

SharePoint REST Get All Columns of a List

The below sample lists all the internal names columns of a list.
<script type="text/javascript">
$(document).ready(function () {
    console.log("ready!!");

$.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('ListName')/items?$select=*",
        type: "GET",
        headers: {
            "accept": "application/json;odata=verbose",
        },
        success: function (data) {
            console.log(data.d.results);
        },
        error: function (error) {
            console.log(JSON.stringify(error));
            alert("Error occured in loading columns!");
        }
    });

});
</script>