1

I can't understand how to build Rest Query (SharePoint Api) to retrieve data from lookup fields. I've tried all that i read. I don't understand how to make right construct of Rest Query. All i've read didn't allow me to make any sence of it.

So, i have one lookup field in list named 'DocumentAuthor'. This field looks to another list 'Organization'. In 'Organization' list we have fields 'Title' or 'Id'.

This does not work:

/_api/Web/Lists(guid'xxx-xxx-xxx...')/Items?$select=DocumentAuthor/Id&$expand=DocumentAuthor

Is returns that "value": "Поле или свойство DocumentAuthor не существует." (translation: "Field or property DocumentAuthor does not exist.").

I have tried this:

/_api/Web/Lists(guid'xxx-xxx-xxx...')/Items?$select=DocumentAuthorId
... as i read in several sites, and this did not help me.


Here are some details about field, returned from rest api

{
        "__metadata": {
            "id": "http://---/_api/Web/Lists(guid'---')/Fields(guid'---')",
            "uri": "http://---/_api/Web/Lists(guid'---')/Fields(guid'---')",
            "type": "SP.FieldLookup"
        },
        "CanBeDeleted": true,
        "DefaultValue": null,
        "Description": "",
        "Direction": "none",
        "EnforceUniqueValues": false,
        "EntityPropertyName": "DocumentAuthor",
        "Filterable": true,
        "FromBaseType": false,
        "Group": "Базовые для документа",
        "Hidden": false,
        "Id": "---",
        "Indexed": false,
        "InternalName": "DocumentAuthor",
        "JSLink": "",
        "ReadOnlyField": false,
        "Required": false,
        "SchemaXml": ",
        "Scope": "/Lists/DocumentsLibrary",
        "Sealed": false,
        "Sortable": false,
        "StaticName": "DocumentAuthor",
        "Title": "Автор документа",
        "FieldTypeKind": 0,
        "TypeAsString": "OrganizationStructureItemsPickerField",
        "TypeDisplayName": "Выбор пользователей из структуры предприятия",
        "TypeShortDescription": "Выбор пользователей из структуры предприятия",
        "ValidationFormula": null,
        "ValidationMessage": null,
        "AllowMultipleValues": true,
        "IsRelationship": true,
        "LookupField": "Title",
        "LookupList": "{zzz}",
        "LookupWebId": "fff",
        "PrimaryFieldId": null,
        "RelationshipDeleteBehavior": 0
    }
0

Try this.

/_api/Web/Lists/GetByTitle('listName')/items?$select=DocumentAuthor/ID,DocumentAuthor/Title&$expand=DocumentAuthor/ID
  • Please add some details to let the OP understand how can use the lookup in REST, Thanks! – Mohamed El-Qassas MVP Aug 30 '17 at 12:02
  • The same error (Field... does not exist) – Daniyar Galiyev Aug 30 '17 at 12:10
  • Please check the internal name of the field used in the rest query is same. – Sharreth Aug 31 '17 at 10:19
  • How to check it? As I mentioned higher it is same "InternalName": "DocumentAuthor" – Daniyar Galiyev Aug 31 '17 at 12:47
0

You are actually doing right. The $expand parameter is used to retrieve field from a lookup ones, then you need to specify fields you want with the $select parameter.

Does

/_api/Web/lists(guid'XXXX')/Items?$select=DocumentAuthor

returns something else than Field or property DocumentAuthor does not exist. ?

  • The value of \"DocumentAuthor\" field cannot be serialized with \"OrganizationStructureItemsPickerField\" type" (original: "Значение поля \"DocumentAuthor\" с типом \"OrganizationStructureItemsPickerField\" не может быть сериализовано.") – Daniyar Galiyev Sep 1 '17 at 12:30
  • Can you translate it please ? – RomainB Sep 1 '17 at 12:32
  • The value of \"DocumentAuthor\" field cannot be serialized with \"OrganizationStructureItemsPickerField\" type" (when I want to put Enter it submitting my Comment :) – Daniyar Galiyev Sep 1 '17 at 12:32
  • No problem. :) If you try to query a single item, do you see this field in results ? – RomainB Sep 1 '17 at 16:57
  • No! I don't. Error "Field or property DocumentAuthor does not exist." – Daniyar Galiyev Sep 4 '17 at 7:08
0

Did you try an expand on the display name instead of static name? If I remember correctly, some SharePoint versions use the display name in REST API.

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.