Skip to content

spHttpClient AddValidateUpdateItemUsingPath() returns status code 200 instead of 500 even though there are errors in the response and the item is not added to the list #7942

@NewGHUser4321

Description

@NewGHUser4321

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

Windows

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version: 100.0.4896.127
  • SPFx version: 1.14.0

Describe the bug / error

When a invalid short URL is sent in the spHttpClient AddValidateUpdateItemUsingPath() request, it is returning status code 200 even though there are errors in the response and, the list item is not added to the list.
If the URL is too long, returns the status code 500 and working as expected.

Here are my request and response details:

Request Headers:

:method: POST
:path: /sites/group/_api/web/GetListUsingPath(DecodedUrl=@a1)/AddValidateUpdateItemUsingPath()?@a1=%27https%3A%2F%2Fsomespo.sharepoint.com%2Fsites%2Fgroup%2FLists%2FTest%20Excel%20Import%27
:scheme: https
accept: application/json
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: no-cache
content-length: 1400
content-type: application/json

Payload for this Request is:

{
  "listItemCreateInfo": {
    "FolderPath": {
      "DecodedUrl": "https://somespo.sharepoint.com/sites/group/Lists/Test Excel Import"
    }
  },
  "formValues": [    
    {
      "FieldName": "Amount_x0020_in_x0020_Local_x002",
      "FieldValue": "125000",
      "HasException": false,
      "ErrorMessage": null
    },
    {
      "FieldName": "Match_x0020_Fee",
      "FieldValue": "25000",
      "HasException": false,
      "ErrorMessage": null
    },
    {
      "FieldName": "Website_x0020_Link",
      "FieldValue": "1234",
      "HasException": false,
      "ErrorMessage": null
    }
  ],
  "bNewDocumentUpdate": false,
  "checkInComment": null,
  "datesInUTC": true
}

Here is field details from above payload in which I'm sending the invalid URL:

{
  "FieldName": "Website_x0020_Link",
  "FieldValue": "1234",
  "HasException": false,
  "ErrorMessage": null
}

Response Code: 200

And the Response is

{
"@odata.context": "https://somespo.sharepoint.com/sites/group/_api/$metadata#Collection(SP.ListItemFormUpdateValue)",
"value": [
{
"ErrorCode": 0,
"ErrorMessage": null,
"FieldName": "Amount_x0020_in_x0020_Local_x002",
"FieldValue": "125000",
"HasException": false,
"ItemId": 0
},
{
"ErrorCode": 0,
"ErrorMessage": null,
"FieldName": "Match_x0020_Fee",
"FieldValue": "25000",
"HasException": false,
"ItemId": 0
},
{
"ErrorCode": -2146232832,
"ErrorMessage": "Invalid URL: 1234.",
"FieldName": "Website_x0020_Link",
"FieldValue": "1234",
"HasException": true,
"ItemId": 0
},
{
"ErrorCode": 0,
"ErrorMessage": null,
"FieldName": "Id",
"FieldValue": "0",
"HasException": false,
"ItemId": 0
}
]
}

Here is the field level response details from the above in which we see error for invalid URL:

{
"ErrorCode": -2146232832,
"ErrorMessage": "Invalid URL: 1234.",
"FieldName": "Website_x0020_Link",
"FieldValue": "1234",
"HasException": true,
"ItemId": 0
}

Steps to reproduce

  1. Create a list with URL field.
  2. Send a spHttpClient request to add list items to the list using AddValidateUpdateItemUsingPath()
  3. Observe that list item is not added but the status code is 200 when a invalid short URL is sent. This is not Expected.
  4. Observe that list item is not added but the status code is 500 when a invalid long URL is sent. This is Expected.
  5. Observe that list item is added with the status code is 200 when a valid URL is sent. This is expected.

Expected behavior

  1. Response code should be 200, only if list item is added to the list whether or not the response contains field level errors as described above.
  2. In the above scenario where the list item is not added because of field level error, the response code should have been 500.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋Original poster responded to request for feedback, awaiting attention from Microsoft / community.area:csom/rest/apiCategory: SharePoint Client Side Object Model SDK / REST APItype:archive-old-issueIssues which are closed as tool old for active worktype:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions