1

I'm trying to update the status column in a document library where the name is "sharepoint_test.csv" and I'm following this tutorial to do it.

URL:

POST:URL

https://mycompany.sharepoint.com/teams/global/commerce/_api/web/lists/GetByTitle('Data%20Sources')/items(4)

Body:

{"__metadata" {"type":"SP.Data.Data_x0020_SourcesItem"},"status":"even newer"}

I've also tried types SP.FieldText and SP.Field.

enter image description here

Here's my library:

Name                | Modified | Modified By | status
-----------------------------------------------------
sharepoint_test.csv | Apr 2    |  Dan        | new

Should become:

Name                | Modified | Modified By | status
-----------------------------------------------------
sharepoint_test.csv | Apr 2    |  Dan        | even newer

When I make the POST request in Postman, however, there is no error, the status comes back as 204 No Content, but when I look back at the status column, it still remains as "new".

According to this and this, I am doing it correctly.

2 Answers 2

1

The column names are case sensitive. Is the column "status" or "Status".

Are you sure the ID of the item is "4"?

Here's what I use that works (for AJAX), which except for the "Authorization" looks to be the same as your example:

/sites/testSite/_api/web/lists/GetByTitle('Announcements')/Items(1)

{ "accept": "application/json;odata=verbose",
  "content-type": "application/json;odata=verbose",
  "X-HTTP-Method": "MERGE",
  "If-Match": "*",
  "X-RequestDigest": "__yourRequestDigest__" }

{ "__metadata": { "type": "SP.ListItem" }, "Title": "New title" }

I have a REST tester that I use to fine tune these requests: http://techtrainingnotes.blogspot.com/2017/04/a-sharepoint-rest-api-tester-with-ajax.html

4
  • For type, it should be [name of list]Item right? I.e., SP.Data.Data_x0020_SourcesItem where _x0020_ is representation of a space. The column name is status, but we've since changed it to Import Status, so I guess the final payload should be {"__metadata":{"type":"SP.Data.Data_x0020_SourcesItem"},"Import_x0020_Status":"TestUpdated"}. You're setting the Title attribute, not the custom library field value?
    – user3871
    Commented Apr 3, 2018 at 3:35
  • Ah got it. Wrong ID as you mentioned. How can I get row by associated filename from a particular specific library rather than by ID?
    – user3871
    Commented Apr 3, 2018 at 3:47
  • Use a filter. For a list: _api/web/lists/getbytitle('Announcements')/items?$filter=Title eq 'Test announcement' For a library file: _api/web/lists/getbytitle('Documents')/Items?$filter=FileLeafRef eq 'AdventureWorksBikes.xlsx'&$select=Title,Id Commented Apr 3, 2018 at 13:46
  • For the REST API, use the static name of fields, so even if you changed the display name to "Import Status" it would still be just status for REST calls. To find the internal name, go to library settings, click the field to edit it, and look at the URL. It will end with &Field=<internal name>, and that's the name you should use for REST.
    – Joe McShea
    Commented Feb 19, 2019 at 10:38
1

Apparently the status of Update Document metadata using REST API is :

nocontent: {"readyState":4,"responseText":"","status":204,"statusText":"No Content"}

So this word shouldn't worry you just check and see if the field changed?

Also you can use at least these two type of REST Endpoint for url for updation document metadata, which both of them return the above result as success!

url:response.d.ListItemAllFields.__metadata.uri,
url=_spPageContextInfo.webAbsoluteUrl+
"/_api/Web/lists/GetByTitle('Documents')/items("+itemId+")";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.