Label requires ad-hoc protection, but protection has not yet been set. Call FileHandler::SetProtection with ad-hoc protection settings before calling FileHandler::SetLabel. This error occurs

hi 0 Reputation points
2024-01-29T04:15:54.1033333+00:00

If you try to call SetLabel() with a labelId that does not have an associated templateId, you will receive the following error: What causes it? Label requires ad-hoc protection, but protection has not yet been set. Call FileHandler::SetProtection with ad-hoc protection settings before calling FileHandler::SetLabel

Azure Information Protection
Azure Information Protection
An Azure service that is used to control and help secure email, documents, and sensitive data that are shared outside the company.
528 questions
{count} votes

1 answer

Sort by: Most helpful
  1. James Hamil 22,976 Reputation points Microsoft Employee
    2024-01-29T19:49:21.3833333+00:00

    Hi @hi , this error occurs when you try to call SetLabel() with a labelId that does not have an associated templateId. The label requires ad-hoc protection, but protection has not yet been set. To resolve this error, you need to call FileHandler::SetProtection with ad-hoc protection settings before calling FileHandler::SetLabel. This will associate a templateId with the labelId and allow you to set the label successfully. Please let me know if you have any questions and I can help you further. If this answer helps you please mark "Accept Answer" so other users can reference it.

    Thank you,

    James

    0 comments No comments