I am trying to update SharePont search result page using Rest API. Trying to update property bag SRCH_x005f_SB_x005f_SET_x005f_SITE / SRCH_x005f_SB_x005f_SET_x005f_WEB however it returns 204 status code.
I need to use rest api only. Is there any solution to this?
Loading


Naimish MakwanaRank #324 · 7.7K reputationPosted Jul 9, 2024, 3:42 AM EDT
The 204 status code you’re seeing is actually a success status. It means that the server successfully processed the request, but is not returning any content1. This is a common response from REST APIs when updating data2.
SharePoint REST API does not return the updated item/object after updating it. It only returns status code 204 if the update request is successful23. If you want to get the updated item/object, you have to make another GET request23.
Here’s an example of how you can do this in JavaScript:
function updateItem(url, success) { $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + url, type: "PATCH", headers: { "accept": "application/json;odata=verbose", }, success: function (data) { console.log("Update successful"); success(); }, error: function (error) { alert(JSON.stringify(error)); } }); } function getItem(url, success) { $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + url, type: "GET", headers: { "accept": "application/json;odata=verbose", }, success: function (data) { console.log(data.d.results); success(data.d.results); }, error: function (error) { alert(JSON.stringify(error)); } }); } // Update the item updateItem("/_api/Web/Lists/GetByTitle('YourListName')/Items(YourItemId)", function() { // After successful update, get the updated item getItem("/_api/Web/Lists/GetByTitle('YourListName')/Items(YourItemId)", function(data) { var result = data; // Use 'result' variable }); });In this example,
updateItemis used to update the item, and thengetItemis called within the success callback ofupdateItemto retrieve the updated item4. This way, you can see the updated item after a successful update. Please replace'YourListName'andYourItemIdwith your actual List Name and Item ID.Thanks