Fixing the KingswaySoft unauthorized error on long Dataverse runs
Diesen Beitrag auf Deutsch lesen
Authentication tokens expire during long KingswaySoft pagination against Dataverse. Renewing the IOrganizationService and retrying keeps the run alive.
TL;DR
KingswaySoft custom code using IOrganizationService can fail with an HTTP unauthorized Anonymous error when Dataverse pagination runs long, because the authentication token expires and is never refreshed. The fix renews the CRM service inside a catch block, waits three seconds and retries the request. Test custom scripts with large data volumes so long-running pagination stays reliable.
Original by Temmy Raharjo, on Temmy Raharjo's Blog. Read the original
This is our own summary, not a republication or full translation.
Governance takeaway
- Makers: when a KingswaySoft Script Component paginates through large Dataverse volumes, wrap service calls in a retry that renews the IOrganizationService, because tokens expire mid-run.
- Admins/CoE: treat the unauthorized Anonymous error in long integration runs as token expiry rather than a permissions failure, and expect long pagination to need re-authentication.
- Security/Compliance: check that custom Dataverse integration code renews its service instance on failure instead of holding one connection for the whole run.
Frequently asked questions
Why does KingswaySoft return HTTP request is unauthorized with client authentication scheme Anonymous against Dataverse?
The authentication token expires while pagination runs for a long time, and the custom code never renews the service instance, so later requests fail.
How do I fix the unauthorized error in a KingswaySoft Script Component?
Renew the IOrganizationService instance inside a catch block, wait three seconds and retry the request, so the expired token gets replaced.
Does KingswaySoft support reading unmasked data with the UnMaskedData parameter in Dataverse?
No, KingswaySoft did not support UnMaskedData reads, so custom code in a Script Component or Script Task was needed to retrieve unmasked data.