0

So in a custom .aspx form, I use an AJAX call to get current list item data.

  1. When I copy "MYSITE" into my browser, I get a page that looks like a blank RSS feed. Any idea as to why this is? The code below (and obviously I didn't paste most of it) works great for what I need. But I'd like to access all my column names, etc. The few ways I've attempted reaching that information I've been denied in several different ways.

  2. If I console.log($this) after the code below, I get my column names but they're chopped off. My question is: Why do some column names tack on the "OData_" prefix?

$.ajax({
    url: "MYSITE",
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    success: function(data){

      $.each(data.d.results, function(index) { etc....

(I can't get the code block to format correctly here)

0

You can get all fields information of list like this.

$.ajax({
url: "/_api/web/lists/GetByTitle('Test')/fields",
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function(data){
  console.log(data.d);
        }
});
0

I think below will answer both your questions

You can use below url to get all your columns names.

https://yoursites/sites/dev/_api/Web/Lists/GetByTitle('MyCustomList')/Fields?&$select=StaticName,Title

Below is sample response for your reference.

    {
    "results": [
        {
            "__metadata": {
                "id": "https://yourdomain/sites/dev/_api/Web/Lists(guid'7dcfd6ad-3126-43db-83d5-d712332a3')/Fields(guid'03e412384-1992-4d42-9116-26f756012634')",
                "uri": "https://yourdomain/sites/dev/_api/Web/Lists(guid'7dcfd6ad-3126-43db-83d5-d7e12378332a3')/Fields(guid'03e4123e84-1992-4d42-9116-26f756012634')",
                "type": "SP.Field"
            },
            "StaticName": "ContentTypeId",
            "Title": "Content Type ID"
        },
        {
            "__metadata": {
                "id": "https://yourdomain/sites/dev/_api/Web/Lists(guid'7dcfd6123ad-3126-43db-83d5-d7e123332a3')/Fields(guid'fa5123e0f-0c70-4ab9-b863-0177e6ddd247')",
                "uri": "https://yourdomain/sites/dev/_api/Web/Lists(guid'7dcf123d6ad-3126-43db-83d5-d7e96123332a3')/Fields(guid'fa213e0f-0c70-4ab9-b863-0177e6ddd247')",
                "type": "SP.FieldText"
            },
            "StaticName": "Title",
            "Title": "Title"
        },
        {
            "__metadata": {
                "id": "https://yourdomain/sites/dev/_api/Web/Lists(guid'7dcf123-3126-43db-83d5-d7e9678332a3')/Fields(guid'34ad123eb-75bd-4544-8c73-0e08330291fe')",
                "uri": "https://yourdomain/sites/dev/_api/Web/Lists(guid'7dcf2136ad-3126-43db-83d5-d7e9678332a3')/Fields(guid'34ad1231eb-75bd-4544-8c73-0e08330291fe')",
                "type": "SP.FieldMultiLineText"
            },
            "StaticName": "_ModerationComments",
            "Title": "Approver Comments"
        }
    ]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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