Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Retrieving Values from nested Objects REST API SharePoint

$
0
0

Hi,

i'm struggling to figure out how to pull data from nested objects using the REST Api. i'm trying to retrieve the values of a category list from my blogs site which is a lookup column to the posts list in the blog. Issues is the values are nested deep within multiple objects. any help will do on how i can pull the highlighted values in the attached snippet.

var glblognews = function getBlogItems () {

         // execute AJAX request
        $.ajax({
            url: _spPageContextInfo.webAbsoluteUrl + "/Blog/_api/web/lists/getbytitle('Posts')/items?

$select=Title,PostCategory/Title,Region/Title&$expand=PostCategory,Region",
            type: "GET",
            headers: { "ACCEPT": "application/json;odata=verbose" },
            success: function (data) {

		var dataRes = data.d.results;
                var dataRes2;

              for (i=0; i< data.d.results.length; i++) {

		console.log(dataRes[i].Title);
		dataRes2 = dataRes[i].PostCategory;
		console.log(dataRes2);

             }

                  },
            error: function () {
            alert("Failed to get details");

            }
        });
    }

Any pointers will help please.

thanks



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>