WebAPI 查询lookup字段的属性

参考:微软官方介绍

通过expand查找

Request

GET [Organization URI]/api/data/v9.1/accounts(3DC1BF70-377D-EA11-B803-837049FBACB3)?$select=name&$expand=primarycontactid($select=contactid,fullname) HTTP/1.1  
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0

解释:

  • $expand=primarycontactid:primarycontactid就是要查找的lookup字段名
  • ($select=contactid,fullname):有这句表明只查找指定字段,不写会查找lookup字段的所有属性

Response

HTTP/1.1 200 OK  
Content-Type: application/json; odata.metadata=minimal  
OData-Version: 4.0  
  
{  
   "@odata.context":"[Organization URI]/api/data/v9.1/$metadata#accounts(name,primarycontactid,primarycontactid(contactid,fullname))",
   "value":[       
      {  
         "@odata.etag":"W/\"513489\"",
         "name":"Alpine Ski House (sample)",
         "accountid":"44dbf27c-8efb-e511-80d2-00155db07c77",
         "primarycontactid":{  
            "contactid":"aadbf27c-8efb-e511-80d2-00155db07c77",
            "fullname":"Paul Cannon (sample)"
         }
      }
   ]
}

WebAPI 查询lookup字段的属性

上一篇:win10安装jenkins忘记密码的解决方法


下一篇:winform自动更新