Get and Update Document Library Added Column via Rest API
-
16-12-2020 - |
Question
I have created a document library in sharepoint 2016 and have added a single-line column.
We have a user-interface where the user select a file to upload and input values for the Title and the new column.
Now, what I am doing is that I am updating the document library in javascript via the sharepoint rest api (mysite/_api/somemethod) and I am able to retreive and update the document libraries default columns (eg. Title) with no problems. (https://msdn.microsoft.com/en-us/library/office/dn769086.aspx)
However, the single-line text column that I have just added is not included on the return of the REST API and so I am also unable to update its value.
We have tried creating a column in Site Columns to see if it will be included on the REST API, but no luck. we have also tried explicitly specified the new column on $select but still no luck.
Hoping anyone can shed me a light on this matter. thank you.
Solution
First inspect if your Field was properly added, if you don't get it with $expand (and your syntax is correct) then it is not there
Install the SharePoint Insider Chrome Extension
or Use Bram de Jager his Client Browser http://spcb.codeplex.com/
and verify all the ContentTypes are correct and have the Fields you are after
Especially look for Display AND Internalname notations
After that; make very very sure your REST syntax is correct, fieldnames are correct, you are on the correct SiteCollection, you are using the proper GUIDs or whatever
OTHER TIPS
do you have set the checkbox 'add to all content types' during the creation of the new column? If not, maybe the content type document will not have this new column. Do you see the new column in the edit properties dialog of the document? BR Andreas