0. SharePoint 2013使用_api来标识出 REST SERVICE,REST Service其实是 client.svc web service的一部分,但为了简化 REST URI的构造以及缩短REST URI的长度,使用 _api 来替代 _vti_bin/client.svc,例如, 你可以使用 http://server/site/_vti_bin/client.svc/web/lists 来替代 http://server/site/_api/web/lists;然而URL有256字符长度的限制,所以建议使用 _api 惯例;可参考此文章中的 Reference the SharePoint 2013 REST service in your endpoint URI 章节;
SharePoint 2013 REST Syntax Posters.pdf
工具:Chrome浏览器中的 Advanced Rest Client Application插件
1. Search REST API的query(GET)可以设置返回json格式的结果,存储在data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results中,results是个数据集合,序号从0开始;
2. 使用REST API获取(GET)数据时,若返回多条记录,则返回值存储在data.d.results中,results是个数据集合,序号从0开始,每一个result包含一个对象单元信息,例如:一个List Item的所有属性,如代码所示;若返回单条记录,则返回值存储在data.d中;
{ "__metadata":{"id":"b719e719-e4cc-445c-9c7c-0250aba4338a", "uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)", "etag":"\"4\"","type":"SP.Data.TasksListItem"}, "FirstUniqueAncestorSecurableObject":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/FirstUniqueAncestorSecurableObject"}}, "RoleAssignments":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/RoleAssignments"}}, "AttachmentFiles":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/AttachmentFiles"}}, "ContentType":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/ContentType"}}, "FieldValuesAsHtml":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/FieldValuesAsHtml"}}, "FieldValuesAsText":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/FieldValuesAsText"}}, "FieldValuesForEdit":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/FieldValuesForEdit"}}, "File":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/File"}}, "Folder":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/Folder"}}, "ParentList":{"__deferred":{"uri":"https://gjq-11683d04060f3b.sharepoint.com/BasicOperationApp/_api/Web/Lists(guid'b44e6daf-ee1e-4249-987f-2f9305cdc884')/Items(1)/ParentList"}}, "FileSystemObjectType":0, "Id":1, "ContentTypeId":"0x0108005943A401D04CAD47AE81ABAA54AA39A3", "Title":"Test", "PredecessorsId":{"__metadata":{"type":"Collection(Edm.Int32)"},"results":[]}, "Priority":"(2) Normal", "Status":"Not Started", "PercentComplete":0.79, "AssignedToId":11, "TaskGroupId":null, "Body":"<div></div>", "StartDate":"2014-08-10T16:00:00Z", "DueDate":"2014-08-27T16:00:00Z", "RelatedItems":null, "WorkflowLink":null, "OffsiteParticipant":null, "OffsiteParticipantReason":null, "WorkflowOutcome":null, "WorkflowName":null, "GUID":"2c618f60-7fae-4689-a652-52458ae60dd6", "ID":1, "Modified":"2014-08-12T03:41:59Z", "Created":"2014-08-11T01:57:18Z", "AuthorId":11, "EditorId":11, "OData__UIVersionString":"4.0", "Attachments":false }