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
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
- Create a list with URL field.
- Send a spHttpClient request to add list items to the list using AddValidateUpdateItemUsingPath()
- Observe that list item is not added but the status code is 200 when a invalid short URL is sent. This is not Expected.
- Observe that list item is not added but the status code is 500 when a invalid long URL is sent. This is Expected.
- Observe that list item is added with the status code is 200 when a valid URL is sent. This is expected.
Expected behavior
- 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.
- In the above scenario where the list item is not added because of field level error, the response code should have been 500.
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
Additional environment details
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:
Payload for this Request is:
Here is field details from above payload in which I'm sending the invalid URL:
And the Response is
Here is the field level response details from the above in which we see error for invalid URL:
Steps to reproduce
Expected behavior