Skip to content

SharePoint Error Codes Reference

HomeDocumentationReference → Error Codes

Overview

This document provides a comprehensive reference of SharePoint error codes used in the mock server implementation. These error codes align with Microsoft SharePoint's standard error responses to ensure compatibility with client applications.

SOAP Error Codes

Format

SOAP errors follow the standard SOAP fault format:

<soap:Fault>
    <faultcode>soap:Server</faultcode>
    <faultstring>Error message</faultstring>
    <detail>
        <errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x8107XXXX</errorcode>
    </detail>
</soap:Fault>

Common SOAP Error Codes

Error Code Hex Value Description Usage
-2147467259 0x80004005 Unspecified error Generic server errors
-2147024809 0x80070057 Invalid parameter Invalid input validation
-2147024894 0x80070002 File not found List/item/file doesn't exist
-2147024891 0x80070005 Access denied Permission failures
-2147024713 0x800700B7 Already exists Duplicate creation attempts
-2130575323 0x81070215 List item not found Specific to list operations
-2130575251 0x8107026D Field not found Field doesn't exist in list
-2130575252 0x8107026C List not found List GUID/name invalid
-2130575238 0x8107027A View not found View doesn't exist
-2147024882 0x8007000E Out of memory Resource exhaustion

REST API Error Codes

Format

REST errors follow OData v4 error format:

{
    "error": {
        "code": "-2147024894, Microsoft.SharePoint.SPException",
        "message": {
            "lang": "en-US",
            "value": "File Not Found."
        }
    }
}

HTTP Status Codes

Status Code Description Usage Scenarios
200 OK Successful GET/POST/PATCH
201 Created Successful POST creating resource
204 No Content Successful DELETE
400 Bad Request Malformed request, validation errors
401 Unauthorized Missing/invalid authentication
403 Forbidden Authenticated but lacking permissions
404 Not Found Resource doesn't exist
409 Conflict Resource already exists, version conflict
500 Internal Server Error Unhandled server exceptions
501 Not Implemented Feature not supported

Common REST Error Responses

404 - Resource Not Found

{
    "error": {
        "code": "-2147024894, Microsoft.SharePoint.SPException",
        "message": {
            "lang": "en-US",
            "value": "The specified list was not found."
        }
    }
}

400 - Bad Request

{
    "error": {
        "code": "-2147024809, System.ArgumentException",
        "message": {
            "lang": "en-US",
            "value": "Invalid request parameter."
        }
    }
}

403 - Access Denied

{
    "error": {
        "code": "-2147024891, System.UnauthorizedAccessException",
        "message": {
            "lang": "en-US",
            "value": "Access denied. You do not have permission to perform this action."
        }
    }
}

409 - Conflict

{
    "error": {
        "code": "-2147024713, Microsoft.SharePoint.SPException",
        "message": {
            "lang": "en-US",
            "value": "A list with this name already exists."
        }
    }
}

Validation Error Patterns

Required Field Missing

  • SOAP: faultcode=soap:Server, errorcode=0x80070057
  • REST: 400 Bad Request, code=-2147024809
  • Message: "Required field '{fieldName}' is missing."

Invalid GUID Format

  • SOAP: faultcode=soap:Server, errorcode=0x80070057
  • REST: 400 Bad Request, code=-2147024809
  • Message: "Invalid GUID format."

List Not Found

  • SOAP: faultcode=soap:Server, errorcode=0x8107026C
  • REST: 404 Not Found, code=-2130575252
  • Message: "List '{listName}' does not exist at site with URL '{siteUrl}'."

Item Not Found

  • SOAP: faultcode=soap:Server, errorcode=0x81070215
  • REST: 404 Not Found, code=-2130575323
  • Message: "Item does not exist. It may have been deleted by another user."

Field Not Found

  • SOAP: faultcode=soap:Server, errorcode=0x8107026D
  • REST: 404 Not Found, code=-2130575251
  • Message: "Field '{fieldName}' does not exist."

View Not Found

  • SOAP: faultcode=soap:Server, errorcode=0x8107027A
  • REST: 404 Not Found, code=-2130575238
  • Message: "View '{viewName}' does not exist."

Permission Denied

  • SOAP: faultcode=soap:Server, errorcode=0x80070005
  • REST: 403 Forbidden, code=-2147024891
  • Message: "Access denied. You do not have permission to perform this action or access this resource."

Duplicate Resource

  • SOAP: faultcode=soap:Server, errorcode=0x800700B7
  • REST: 409 Conflict, code=-2147024713
  • Message: "A {resourceType} with the name '{name}' already exists."

Error Handling Best Practices

1. Consistent Error Responses

All endpoints should return errors in the protocol-appropriate format: - SOAP endpoints: Use SOAP fault format - REST endpoints: Use OData v4 error format

2. Include Correlation IDs

All error responses should include the correlation ID for tracing:

SPRequestGuid: {guid}

3. Meaningful Error Messages

  • Use clear, actionable error messages
  • Include the resource name/ID when applicable
  • Suggest remediation steps when possible

4. Log All Errors

Every error should be logged with: - Correlation ID - User context - Request details - Stack trace (for 500 errors)

5. Error Code Consistency

  • Use the same error code for the same error condition
  • Map .NET exceptions to appropriate SharePoint error codes
  • Validate error codes match real SharePoint behavior

Implementation Guidelines

SOAP Controller Error Handling

try
{
    // Operation logic
}
catch (ArgumentException ex)
{
    // Return SOAP fault with 0x80070057
    return CreateSoapFault("soap:Server", ex.Message, "0x80070057");
}
catch (FileNotFoundException ex)
{
    // Return SOAP fault with 0x80070002
    return CreateSoapFault("soap:Server", ex.Message, "0x80070002");
}
catch (UnauthorizedAccessException ex)
{
    // Return SOAP fault with 0x80070005
    return CreateSoapFault("soap:Server", ex.Message, "0x80070005");
}

REST Controller Error Handling

try
{
    // Operation logic
}
catch (ArgumentException ex)
{
    return BadRequest(new {
        error = new {
            code = "-2147024809, System.ArgumentException",
            message = new {
                lang = "en-US",
                value = ex.Message
            }
        }
    });
}
catch (FileNotFoundException ex)
{
    return NotFound(new {
        error = new {
            code = "-2147024894, Microsoft.SharePoint.SPException",
            message = new {
                lang = "en-US",
                value = ex.Message
            }
        }
    });
}

Testing Error Scenarios

Required Test Cases

  1. Invalid GUID formats
  2. Missing required fields
  3. Non-existent resources (list, item, file, etc.)
  4. Permission denied scenarios
  5. Duplicate resource creation
  6. Malformed request payloads
  7. Invalid parameter values
  8. Out of range values

Example Test

[Fact]
public async Task GetList_InvalidGuid_Returns400()
{
    var response = await _client.GetAsync("/_api/web/lists(guid'invalid-guid')");
    Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);

    var error = await response.Content.ReadAsAsync<ODataError>();
    Assert.Contains("-2147024809", error.Error.Code);
}

See Also