First: I am a noob and I use the REST API of SP server with Java, so no SDK involved here.
I uploaded a file to a Document set. Now I have to modify the ContentType and some other custom fields (properties) of the file. I used this kind of endpoint to upload it:
_api/web/getfolderbyserverrelativeurl(''{0}/{1}'')/files/add(overwrite=true, url=''{2}'')?$expand=ListItemAllFields
Where the placeholders will be replaced with:
- serverRelativeUrl
- folder name (docset title)
- file name
I get a response like this:
{
"ListItemAllFields": {
"FileSystemObjectType": 0,
"Id": 488,
"ServerRedirectedEmbedUri": null,
"ServerRedirectedEmbedUrl": "",
"ID": 488,
"ContentTypeId": "0x0101000CAB0B3907F52E45B48A63D0764D7D4E",
"Created": "2021-10-21T11:52:06",
"AuthorId": 11,
"Modified": "2021-10-21T11:52:06",
"EditorId": 11,
"OData__CopySource": null,
"CheckoutUserId": null,
"OData__UIVersionString": "1.0",
"GUID": "bde8b1ba-b7dd-4797-99c7-0e4e8b3cd6ef",
"ComplianceAssetId": null,
"DocumentSetDescription": null,
"TaskItId": null,
"TaskItPriority": null,
"TaskItComments": null,
"TaskItStartDate": null,
"TaskItDueDate": null,
"TaskItInternStatus": null,
"TaskItInternAssignToId": null,
"TaskItInternAssignToStringId": null,
"TaskItInternAssignCcId": [],
"TaskItInternAssignCcStringId": [],
"TaskItPlannedSteps": null,
"TaskItContactNotes": null,
"TaskItResults": null,
"TaskItExternStatus": null,
"TaskItExternAssignTo": null,
"TaskItExternAssignCc": null,
"TaskItMailSubject": null,
"TaskItMailSender": null,
"TaskItMailReceiver": null,
"TaskItMailReceiptDate": "2021-10-21T11:52:06"
},
"CheckInComment": "",
"CheckOutType": 2,
"ContentTag": "{62DFBCF6-7236-4A5E-A39E-BEA836D26E92},1,1",
"CustomizedPageStatus": 0,
"ETag": "\"{62DFBCF6-7236-4A5E-A39E-BEA836D26E92},1\"",
"Exists": true,
"IrmEnabled": false,
"Length": "2400",
"Level": 1,
"LinkingUri": null,
"LinkingUrl": "",
"MajorVersion": 1,
"MinorVersion": 0,
"Name": "mail ne mail mit zeug und so_f.eml",
"ServerRelativeUrl": "/websites/A0000023/TaskItLibrary/neue Aufgabe mit Attachments/mail ne mail mit zeug und so_f.eml",
"TimeCreated": "2021-10-21T09:52:06Z",
"TimeLastModified": "2021-10-21T09:52:06Z",
"Title": null,
"UIVersion": 512,
"UIVersionLabel": "1.0",
"UniqueId": "62dfbcf6-7236-4a5e-a39e-bea836d26e92"
}
The fields starting with "TaskIt" are the custom fields I want to change and also the content type of the element itself by using a certain content type ID.
Now I am trying to modify the data using this endpoint
_api/Web/GetFileByServerRelativePath(decodedurl='/websites/A0000023/TaskItLibrary/neue%20Aufgabe%20mit%20Attachments/mail%20ne%20mail%20mit%20zeug%20und%20so_f.eml')
Method is POST, the header contains a valid request digest etc. I am sending JSON data like this:
{
"foo":"bar"
}
but whatever I try to modify (not "foo" of course) will result in the error which says:
"the given parameter does not exist in the method "getfilebyserverrelativepath" " (translated from German here, so I hope you recognize this error). It's a
Microsoft.SharePoint.Client.InvalidClientQueryException
There must be some voodoo on how to modify a file in a Document set so I hope for a solution here.