SharePoint Online - Call a SharePoint web service

Use the SharePoint Online - Call a SharePoint web service action A tool for building the processes, logic, and direction within workflows. to make REST API calls to SharePoint Online. You can configure the action to return the response content in an output variable. The format of the response header is always JSON, whereas, the response content can either be JSON or XML, depending on the configuration of the request headers.

For example, if your workflow requires retrieving information about a SharePoint Online list item, the SharePoint Online - Call a SharePoint web service action makes a HTTP Get request to SharePoint Online through the SharePoint platform API. SharePoint then returns details about the specified SharePoint Online list item. See Step-by-step example: Make a HTTP Get request to retrieve information about a SharePoint Online list item and extract a property.

You may also want to update a list item in a SharePoint Online list; the SharePoint Online - Call a SharePoint web service action makes a HTTP Post request to SharePoint Online through the SharePoint platform API. SharePoint then updates the list. See Step-by-step example: Make a HTTP Post request to update the title of a SharePoint Online list item.

Before you start 

Configure the SharePoint Online - Call a SharePoint web service action

The steps required to configure the action are given below. The required and optional configuration fields are described in the SharePoint Online - Call a SharePoint web service action fields and selections.

In the Designer page:

  1. Select a Connection.

  2. In URL, type your SharePoint URL or select a variable that holds your request URL.
  3. Select a Request type.
  4. In Request headers, type your request headers or insert a variable that stores the headers of your HTTP request.
  5. In Request content, type your request content or insert a variable that stores the content of your HTTP request.

Step-by-step example: Make a HTTP Get request to retrieve information about a SharePoint Online list item and extract a property

This example retrieves the information about a SharePoint Online list item and extracts a property from SharePoint's response content. We will use the Query JSON action to extract the property value from SharePoint Online - Call a SharePoint web service's JSON-based output. To verify the retrieved information, we will add Log to instance details actions to the workflow.

In the Designer page:

  1. Add the  SharePoint Online - Call a SharePoint web service action to the workflow.
  2. Select or create a Connection.
  3. In URL, type your SharePoint URL or select a variable that holds your request URL, using the following format:
  4. https://SharePoint URL path/_api/web/lists('List ID')/Items(Item ID)

    For example:

    https://anyname.sharepoint.com/sites/foldername/_api/web/lists('ab12345c-d123-456e-f78a-9012bc34567d')/Items(1)
  5. In the Request type field, select HTTP Get.
  6. In the Output section, click the Result field to add a variable.
    1. In the Insert variables panel, make sure SharePoint Online is selected, and then click Create variable.
    2. The Create variable panel appears.

    3. In the Name field, type SPGetOuput.
    4. Click Create & Insert.
  7. Use the default Request header displayed in the Request header field.
  8. Accept: application/json;odata=verbose
    Content-Type: application/json;odata=verbose
  9. Add the Log to instance details action to the workflow, and configure the action:
    1. In the Message field, click Insert to insert a variable.
    2. In the Insert variables pane, click SharePoint Online.
    3. Expand SPGetOutput.
    4. Insert Response content.
  10. Add the Query JSON action to the workflow, and configure the action:
    1. In the JSON source field, insert a variable from the SharePoint output.
      1. Click Insert.
      2. The Insert variables panel appears.

      3. Click SharePoint Online, and then expand SPGetOutput.
      4. Insert Response content.
    2. In the JSONPath Expression field, enter the following code:
    3. Copy

      $['d']['__metadata']['type']
    4. In the Store first result field, add a variable called itemType.
  11. Add the Log to instance details action to the workflow, and configure the action:
    1. In the Message field, click Insert to insert a variable.
    2. In the Insert variables pane, click Workflow.
    3. Insert itemType.
  12. Publish the workflow and check the result in the Instances page.
  13. The output for the first Log to instance details action should show the retrieved details about the SharePoint list item that you specified in the URL. The second Log to instance details action should show the value of the property that is extracted from the Response content. You can further add more actions to your workflow to use or modify the retrieved details.

    For information on the format of the URL path, request headers, or request content, see the Microsoft SharePoint API documentation.

Step-by-step example: Make a HTTP Post request to update the title of a SharePoint Online list item

This example updates the title of the first item in a SharePoint Online list.

In the Designer page:

  1. Add the  SharePoint Online - Call a SharePoint web service action to the workflow.
  2. Select or create a Connection.
  3. In URL, type your SharePoint URL or select a variable that holds your request URL, using the following format:
  4. https://SharePoint URL path/_api/web/lists('List ID')/Items(Item ID)

    For example:

    https://anyname.sharepoint.com/sites/foldername/_api/web/lists('ab12345c-d123-456e-f78a-9012bc34567d')/Items(1)
  5. In the Request type field, select HTTP Post.
  6. In the Request headers field, enter the following headers:
  7. Accept: application/json;odata=verbose
    Content-Type: application/json;odata=verbose
    If-Match: *
    X-HTTP-Method: MERGE
    Note: 
    • For the If-Match property, we'll use "*" to match and update any version of the specified list item. The version of the list item would no longer be checked. For more information on using If-Match, see the If-Match documentation.

    • X-HTTP-Method is included only in requests that use HTTP Post to perform other operations, such as Merge, Delete, or Put. For more information, see the Properties used in REST requests.

  8. In the Request content field, enter the following payload:
  9. {
    "__metadata":
    {
    "type": "List item type"},
    "Title": "UpdatedTitle"
    }

    Note: List item type depends on your SharePoint Online list. For example, "SP.Data.TestListItem".

  10. Test or publish your workflow, and check your SharePoint Online list.
  11. The title of the first item in the list should be displayed as UpdatedTitle.

    For information on the format of the URL path, request headers, or request content, see the Microsoft SharePoint API documentation.