SharePoint HTTP Request

Perform an HTTP request to SharePoint using the PnPjs 'sp' object

Overview

This node performs custom HTTP requests to a SharePoint site using the PnPjs library. It allows users to specify any SharePoint REST API endpoint relative to a given site URL, along with HTTP method, query parameters, headers, and request body. This flexibility makes it useful for scenarios where built-in SharePoint nodes do not cover specific API calls or when advanced/customized interactions with SharePoint are needed.

Practical examples:

  • Retrieving lists or list items with complex filters.
  • Creating or updating SharePoint list items or documents.
  • Deleting resources in SharePoint.
  • Calling custom SharePoint REST endpoints or extensions.

Properties

Name Meaning
Site URL The base URL of the SharePoint site (e.g., https://contoso.sharepoint.com/sites/example).
HTTP Method The HTTP method to use for the request. Options: DELETE, GET, PATCH, POST.
Site Relative Endpoint URL The endpoint path relative to the site URL (e.g., /_api/web/lists).
Query Parameters Optional JSON object representing query parameters to append to the URL (e.g., { "$top": 5 }).
Headers Optional JSON object representing additional HTTP headers to include in the request (e.g., { "Accept": "application/json" }).
Body Optional JSON object representing the request body, used mainly for POST, PATCH, or PUT methods (e.g., { "Title": "Sample" }).

Output

The node outputs an array of items where each item contains a json property holding the parsed response from the SharePoint REST API call. The structure of this JSON depends on the specific SharePoint endpoint called and the data returned by that endpoint.

If the response includes binary data, it is not explicitly handled or output by this node based on the static code analysis.

Dependencies

  • Requires an API authentication token credential configured for SharePoint access.
  • Uses the PnPjs library internally to perform SharePoint REST API calls.
  • Requires proper permissions on the SharePoint site to perform the requested operations.

Troubleshooting

  • JSON Parsing Errors: If query parameters, headers, or body inputs are not valid JSON strings, the node logs an error and may fail. Ensure these fields contain valid JSON.
  • Authentication Failures: The node requires a valid SharePoint API authentication token. Invalid or expired credentials will cause errors.
  • Invalid URLs or Endpoints: Incorrect site URLs or relative endpoint paths can lead to failed requests. Verify the URLs carefully.
  • Unsupported HTTP Methods: Only DELETE, GET, PATCH, and POST are supported. Using other methods will cause errors.
  • Request Body Issues: For POST, PATCH, or PUT methods, ensure the body is correctly formatted JSON matching the expected schema of the SharePoint endpoint.

Links and References

Discussion