API - WSU-GC/sharepoint-2013-docs GitHub Wiki
Json object all POST methods accept. Not all fields are used by all POST methods.
-
Query
|string: Caml Query. -
ViewFields
|string[]: The list columns to include in the response. These should be theInternalName
s of the fields you want to return. Use/api/lists/fields/:listId[string|Guid]
to find all the fields and their internalnames for a list. -
Status
|string: used by/api/tasks/
-
NotStatus
|string: -
UpdateMap
|Dictionary<string, object>: Define the fields and their values to store. Used in both Create and Update POST methods. -
PersonMap
|Dictionary<string, object>: Define fields that are users as those need to be inserted by doing a user lookup first. Keys should be the field that will contain the user entry and the value is the user's NID. Do not include these fields in the UpdateMap. Used in Create and Update POST methods. -
Editor
|string: Set the ListItem'sEditor
field to a specific user (impersonation in conversation). Value should be a NID.
Note The ViewFields cannot be empty. All Post methods require returning at least one field. If you dont need any return data still specify at least one field, ex: ID, to be returned in the ViewFields property.
Json response object for all api calls. Not all fields are populated in each call.
-
ListTitle
|string -
ListId
|Guid -
ItemTitle
|string: Currently only used by workflow api. -
ItemId
|int: Currently only used in workflow api. -
ListFields
|List<Dictionary<string, string>>: The possible fields and their internal names for a particular list. -
ListItems
|List<Dictionary<string, object>>: The ListItems that match the CamlQuery
provided by thePostSPCamlQuery
object in the POST call. Will contain the fields specified byViewFields
inPostSPCamlQuery
.
All controller actions accept an optional contextUrl
url parameter that will change the site collection in which the action will run.
Example /api/lists/?contextUrl=https://sharepointdev.gc.wsu.edu
will retrieve all lists for the root site collection. The default site collection is /sites/globalcampus
None
None
-
ListItems
: Includes and Id and Title field.
-
listId
[Guid|string]: Can be either a list id (Guid) or title.
None
ListId
ListTitle
ListItems
Same as /api/listitem/getall/:listId
-
listId
[Guid|string]: Can be either a list id (Guid) or title.
Query
ViewFields
ListId
ListTitle
ListItems
POST /api/lists/getbytitle/Exam Verification
HEADERS:
Content-Type: application/Json
Body:
{
"ViewFields": ["ID", "Title", "course_id"],
"Query": "<View><Query><Where><Eq><FieldRef Name='course_id'/><Value Type='Text'>2011_spr_pul_F-A_101_merge</Value></Eq></Where></Query></View>"
}
-
listId
[Guid|string]: Can be either a list id (Guid) or title. -
itemId
|int
ViewFields
ListId
ListTitle
-
ListItems
: Returns a list with a single item.
POST /api/listitem/get/Exam Verification/84
HEADERS:
Content-Type: application/Json
Body:
{
"ViewFields": ["ID", "Title", "course_id"]
}
Much like /api/listem/get/:listId/:itemId
except this accepts a query to find a single item instead of an itemId
. Still returns a list with a single entry even if the passed in query returns multiple results (returns first result).
-
listId
[Guid|string]: Can be either a list id (Guid) or title. -
itemId
|int
Query
ViewFields
ListId
ListTitle
-
ListItems
: Returns a list with a single item.
POST /api/listitem/get/Exam Verification
HEADERS:
Content-Type: application/Json
Body:
{
"ViewFields": ["ID", "Title", "course_id"]
}
// Still returns one item even if Query is not provided.
-
listId
[Guid|string]: Can be either a list id (Guid) or title.
ViewFields
UpdateMap
PersonMap
Editor
ListId
ListTitle
ListItems
POST /api/listitem/create/Task Assignment
HEADERS:
Content-Type: application/Json
Body:
{
"ViewFields": ["ID", "Title", "course_id", "user", "Role"],
"UpdateMap": {
"Title": "Not Kyle",
"course_id": "2011_spr_pul_F-A_101_merge",
"course_space_ID": -1,
"Role": "Something"
},
"PersonMap": {
"user": "nid"
}
}
Note: in the above example the course_id is a BCS field so you must set the corresponding ID field to -1.
-
listId
[Guid|string]: Can be either a list id (Guid) or title. -
itemId
|int
ViewFields
UpdateMap
PersonMap
Editor
ListId
ListTitle
ListItems
POST /api/listitem/update/Exam Verification/86
HEADERS:
Content-Type: application/Json
Body:
{
"ViewFields": ["ID", "Title", "course_id"],
"UpdateMap": {
"Title": "Not Kyle",
"conversation": "I'm Ron Burgandy?"
},
"Editor": "NID"
}
Note: Setting the Editor field above will impersonate that user for adding to the conversation.
Note: This method returns an anonymous object instead of an instance of SPApiResponse. The object contains WorkflowCount
field which is a dictionary that breaks down the number of workflows that are in each state.
-
listId
|Guid: In most places this can be either a Guid or string but workflows must load by list ID. -
itemId
|int
None
Returns a custom object. Run in rest client to see an example response.
Method will return all tasks associated to list item itemId
that belongs to the list listId
from the Workflow Tasks list. Will return the tasks based on modified date in desc order.
-
listId
|Guid: Must be Guid of the list. -
itemId
|int
-
taskListTitle
|string: This is an optional paremeter to specify which list to use to look up the associated tasks. By default this is Workflow Tasks
ViewFields
Status
NotStatus
Note Will only accept either Status
or NotStatus
. Method will only honor the Status
filter if bother parameters are provided.
ListId
ListTitle
ListItems
POST /api/task/get/f451700f-b362-41c8-98cc-e6e9bd24dd95/86
HEADERS:
Content-Type: application/Json
Body:
{
"ViewFields": ["Title", "ID", "Description", "Status", "PercentComplete", "Checkmark", "TaskOutcome", "AssignedTo"],
"NotStatus": "Completed"
}
The above example will return all associated tasks that are not complete so including tasks that are not started, in progress and suspended. As opposed to passing in the filter Status: "Not Started" which would have only returned not started tasks.
Note This is the same as calling /api/lists/getbytitle/:listId
with the following data
POST /api/lists/getbytitle/Workflow Tasks
HEADERS:
Content-Type: application/Json
Body:
{
"ViewFields": ["Title", "ID", "Description", "Status", "PercentComplete", "Checkmark", "TaskOutcome", "AssignedTo"]
"Query": "<View><Query><Where><And><Contains><FieldRef Name='RelatedItems'/><Value Type='Text'>LISTGUID</Value></Contains><And><Contains><FieldRef Name='RelatedItems'/><Value Type='Text'>ITEMID</Value></Contains><Eq><FieldRef Name='Status'/><Value Type='Text'>STATUS</Value></Eq></And></And></Where><OrderBy><FieldRef Name='Modified' Ascending='FALSE'/></OrderBy></Query></View>"
}
Notice the above call goes directly to the Workflow Task list and searches the RelatedItems of all task for the correct listId and itemId.
Alias to /api/listitem/update/:listId/:itemId
except you dont need to pass in the listId as this method will work with Workflow Tasks by default. Instead, if you need to overwrite the Task List name then use the taskListTitle
url parameter.
-
itemId
|int: This is the itemId of the task from the Workflow Task list. Not the Id of the associated list item from one of the verification lists.
-
taskListTitle
|string: This is an optional paremeter to specify which list to use to look up the associated tasks. By default this is Workflow Tasks
ViewFields
UpdateMap
Editor
ListId
ListTitle
ListItems
Commenting on a task as a specific user (editor) and advancing the task.
POST /api/task/update/186
HEADERS:
Content-Type: application/Json
Body:
{
"ViewFields": ["Title", "ID", "Body", "Status", "PercentComplete", "Checkmark", "TaskOutcome", "AssignedTo", "Add_x0020_To_x0020_Conversation"],
"UpdateMap": {
"Status": "Completed",
"PercentComplete": 1,
"Checkmark": 1,
"TaskOutcome": "Send to Designer",
"ExamSpecialistTaskOutcome": "Send to Designer",
"Add_x0020_To_x0020_Conversation": "Adding to the conversation"
},
"Editor": "NID"
}
A wrapper to the method above, /api/task/update/:itemId
that will advance the task.
-
itemId
|int: This is the itemId of the task from the Workflow Task list. Not the Id of the associated list item from one of the verification lists. -
outcome
|string: the desired outcome of the task. Example: Send to Designer
-
taskListTitle
|string: This is an optional paremeter to specify which list to use to look up the associated tasks. By default this is Workflow Tasks
ViewFields
UpdateMap
Editor
ListId
ListTitle
ListItems
Commenting on a task as a specific user (editor) and advancing the task.
POST /api/task/advance/186/Send to Designer
HEADERS:
Content-Type: application/Json
Body:
{
"ViewFields": ["Title", "ID", "Body", "Status", "PercentComplete", "Checkmark", "TaskOutcome", "AssignedTo", "Add_x0020_To_x0020_Conversation"],
"UpdateMap": {
"Add_x0020_To_x0020_Conversation": "Adding to the conversation"
},
"Editor": "NID"
}
Notice we did not have to specify the percent complete, status, task outcomes or checkmark fields. These updates are handled for us in this method.