Rest API to update a library item giving 400 error
-
29-01-2021 - |
Question
The code am using:
pnp.sp.web.getFolderByServerRelativeUrl("Shared%20Documents").files.getByName("test.jpg").getItem().then(item => {
item.update({
Title: "A Title",
tag2: "My Other Value"
});
})
error : The property 'tag2' does not exist on type 'SP.Data.Shared_x0020_DocumentsItem'. Make sure to only use property names that are defined by the type.
NOTE: INTERNAL NAME DOES NOT WORK TOO!
Solution
I finally figured out the issue,i was using the wrong internal name. what i did was to go library setting-->select column-->Have a look at the link and look for field=something.
This was the wrong way of looking for the internal name. The correct way was
var item =pnp.sp.web.getFolderByServerRelativeUrl("Shared%20Documents").files.getByName("test.jpg")
console.log(item)
You then consult the body of item to identify the correct internal name.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange