I have the following to look up my standard fields in SharePoint 2013:
var requestURI = _spPageContextInfo.webAbsoluteUrl + "_api/web/lists/getbytitle('" + listname + "')/items?" +
"$select=ID,Title,Status";
$.ajax({
url: requestURI,
method: "GET",
headers: {"Accept": "application/json odata=verbose", "content/type" : "application/json odata=verbose"},
success: function(data) {
$.each(data.d.results, function(index, item) {
console.log('ID: ' + item.ID);
console.log('Title: ' + item.Title);
console.log('Status: ' + item.Status);
}
}
This works fine in returning those three items. I have a problem that I have a field I need to retrieve that has a space in it, "Suspense Status". I had used SPServices previously with SharePoint 2007 and this webPart. With it, I would use "Suspense_x0020_Status" to reference the feield. I have tried that with REST as this:
console.log('Suspense Status: ' + item.Suspense_x0020_Status);
with no luck, as expected, but I am uncertain how to go about getting this information. I have tried a way to look at the JSON XML keys, but haven't had luck doing that either.
Does anyone know ho I could do either, reference the field with a space in its name, or look up all the field names referenced in the sharepoint list? Or both?
Thank You