Repository navigation
Error setting AnchorId of a taxonomy field in a list #1898
|
Hi @Adam-it, The following Error occurs: Could it be possible that PnP.Core should use "SP.Taxonomy.TaxonomyField" instead of "SP.Field" as EntityType. |
Replies: 1 comment 2 replies
|
Your read is right. Until that's fixed, send the update yourself with the correct type: var body = JsonSerializer.Serialize(new
{
__metadata = new { type = "SP.Taxonomy.TaxonomyField" },
AnchorId = anchorId
});
await list.ExecuteRequestAsync(new ApiRequest(
new HttpMethod("PATCH"),
ApiRequestType.SPORest,
$"_api/web/lists(guid'{list.Id}')/fields('{taxonomyListField.Id}')",
body));This is the same request The proper fix belongs in PnP Core: it should send the real field type, or route taxonomy property updates through CSOM like field creation does. That's worth an issue if one doesn't exist yet. |
Your read is right.
Fieldis mapped toSP.Fieldonly ([SharePointType("SP.Field", ...)]inField.cs). PnP Core reads withodata=nometadata, so it never learns that the field is reallySP.Taxonomy.TaxonomyField.UpdateAsyncthen sends__metadata: { type: "SP.Field" }, and SharePoint rejectsAnchorIdon that type.TermSetId,SspIdand the other taxonomy properties would fail the same way. There is also no public API to set the anchor today: the CSOM request used byAddTaxonomyAsynchard-codesAnchorIdtoGuid.Empty(see #1681).Until that's fixed, send the update yourself with the correct type: