5

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

Matthew Dewell
  • 563
  • 7
  • 30

1 Answers1

6

OK, I found the problem. The 'x0020' works fine!!!!!

I neglected to include the field, 'Suspense_x0020_Status' in my '$select=' statement to make it '$select=ID,Title,Status,Suspense_x0020_Status'.

It appears to be going fine now.

Sorry for the trouble.

Matthew Dewell
  • 563
  • 7
  • 30