Aug 28 2020 04:09 AM - edited Aug 28 2020 04:15 AM
Hello Community,
I am trying to implement an API based file upload using the following Microsoft tutorial: https://docs.microsoft.com/de-de/sharepoint/dev/sp-add-ins/upload-a-file-by-using-the-rest-api-and-j...
The upload is already working and I'm stuck on the last step, updating the file metadata.
It was already possible for me to update simple text lines.
But since I unfortunately have to update managed meta data columns as well, I am now stuck with this challenge.
The itemMetadata variable was set as follows and contains the following data of the file:
- etag
- id
- type
- uri
// code to set var itemMetadata
itemMetadata = return jQuery.ajax({
url: fileListItemUri,
type: "GET",
headers: { "accept": "application/json;odata=verbose" }
});
var body = JSON.stringify({
"__metadata":{"type":itemMetadata.type},"Titke":md.Title,"MyManagedMetadataField":{"__metadata":{"type":"SP.Taxonomy.TaxonomyFieldValue"},
"Label":md.metadata.Label,"TermGuid":md.metadata.TermGuid,"WssId":-1}
});
return jQuery.ajax({
url: itemMetadata.uri,
type: "POST",
data: body,
headers: {
"X-RequestDigest": reqDigest,
"content-type": "application/json;odata=verbose",
// "content-length": body.length,
"IF-MATCH": itemMetadata.etag,
"X-HTTP-Method": "MERGE"
},
success: (xhr) => {
deferred.resolve();
console.log("success!?!");
},
error: (xhr) => {
console.log(xhr.responseText);
}
});
Sep 15 2020 10:20 PM
Sep 28 2020 07:47 AM
SolutionAfter contact with Microsoft support we have come to the conclusion that it is not necessary to delete the default values for the columns. The following format is possible and works fine.
The URI only needs to be extended by one function.
{
"formValues":
{
"FieldName": "Metadatacolumn",
"FieldValue": taxItemLabel + '|' + taxItemTermGuid
},
"bNewDocumentUpdate": false
}
Cheers,
Saintenr
Dec 15 2020 03:44 PM
@Saintenr Hello, I am in the process of migrating data to sharepoint and have a requirement to update the metadata for managed MetaData fields for documents uploaded. I need to download the TermGuid for all the items in the TermSet. I will have to then pass the TermGuid and Label to the update document API call. I do not see any REST API avaiable to download the TermSet information for a specific managed meta data field. In your code example I see that you already have this information. Where and how are you getting this information. It would be really helpful if you can tell me how you are getting this information. Thanks so much for your help!
Mar 10 2021 11:45 PM