API - WSU-GC/sharepoint-2013-docs GitHub Wiki

PostSPCamlQuery

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 the InternalNames 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's Editor 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.

SPApiResponse

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 Caml Query provided by the PostSPCamlQuery object in the POST call. Will contain the fields specified by ViewFields in PostSPCamlQuery.

Global URL parameters

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

GET /api/lists

Route parameters

None

PostSPCamlQuery parameters

None

SPApiResponse fields

  • ListItems: Includes and Id and Title field.

GET /api/lists/fields/:listId

Route parameters

  • listId[Guid|string]: Can be either a list id (Guid) or title.

PostSPCamlQuery

None

SPApiResponse fields

  • ListId
  • ListTitle
  • ListItems

POST /api/lists/getbytitle/:listId

Same as /api/listitem/getall/:listId

Route parameters

  • listId[Guid|string]: Can be either a list id (Guid) or title.

PostSPCamlQuery

  • Query
  • ViewFields

SPApiResponse fields

  • ListId
  • ListTitle
  • ListItems

Example

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>"
}

POST /api/listitem/get/:listId/:itemId

Route parameters

  • listId[Guid|string]: Can be either a list id (Guid) or title.
  • itemId|int

PostSPCamlQuery

  • ViewFields

SPApiResponse fields

  • ListId
  • ListTitle
  • ListItems: Returns a list with a single item.

Example

POST /api/listitem/get/Exam Verification/84
HEADERS:
Content-Type: application/Json

Body:
{
  "ViewFields": ["ID", "Title", "course_id"]
}

POST /api/listitem/search/:listId

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).

Route parameters

  • listId[Guid|string]: Can be either a list id (Guid) or title.
  • itemId|int

PostSPCamlQuery

  • Query
  • ViewFields

SPApiResponse fields

  • ListId
  • ListTitle
  • ListItems: Returns a list with a single item.

Example

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.

POST /api/listitem/create/:listId

Route parameters

  • listId[Guid|string]: Can be either a list id (Guid) or title.

PostSPCamlQuery

  • ViewFields
  • UpdateMap
  • PersonMap
  • Editor

SPApiResponse fields

  • ListId
  • ListTitle
  • ListItems

Example

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.

POST /api/listitem/update/:listId/:itemId

Route parameters

  • listId[Guid|string]: Can be either a list id (Guid) or title.
  • itemId|int

PostSPCamlQuery

  • ViewFields
  • UpdateMap
  • PersonMap
  • Editor

SPApiResponse fields

  • ListId
  • ListTitle
  • ListItems

Example

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.

GET /api/workflow/getbylistid/:listId/:itemId

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.

Route parameters

  • listId|Guid: In most places this can be either a Guid or string but workflows must load by list ID.
  • itemId|int

PostSPCamlQuery

None

Response

Returns a custom object. Run in rest client to see an example response.

POST /api/task/get/:listId/:itemId

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.

Route parameters

  • listId|Guid: Must be Guid of the list.
  • itemId|int

URL parameters

  • 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

PostSPCamlQuery

  • ViewFields
  • Status
  • NotStatus

Note Will only accept either Status or NotStatus. Method will only honor the Status filter if bother parameters are provided.

SPApiResponse fields

  • ListId
  • ListTitle
  • ListItems

Example

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.

POST /api/task/update/: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.

Route parameters

  • 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.

URL parameters

  • 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

PostSPCamlQuery

  • ViewFields
  • UpdateMap
  • Editor

SPApiResponse fields

  • ListId
  • ListTitle
  • ListItems

Example

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"
}

POST /api/task/advance/:itemId/:outcome

A wrapper to the method above, /api/task/update/:itemId that will advance the task.

Route parameters

  • 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

URL parameters

  • 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

PostSPCamlQuery

  • ViewFields
  • UpdateMap
  • Editor

SPApiResponse fields

  • ListId
  • ListTitle
  • ListItems

Example

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.

⚠️ **GitHub.com Fallback** ⚠️