Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

The HTTP request is unauthorized with client authentication scheme 'Anonymous'.

Posted on by 1,575

Hello. We have a console app which imports and updates records to our (cloud) dynamics 365 from a SQL table using OrganizationRequestCollection/ExecuteMultipleRequest

If the number of records processed is low there is no issue. Often there is no issue with processing "high" volumes (15k -20k records) but sometimes (- with no consistent cause - it actually seems to vary from job-run to job-run) the import stops (*NOT immediately, but randomly after processing 10 or 14 "chunks" (of 500 rows) with the following error:

error The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Bearer authorization_uri=login.microsoftonline.com/guid_which_i_can’t_reconcile/oauth2/authorize, resource_id=https://our_dynamics_ 365_ url'.

I can't stress enough - , the error is inconsistent - 95% of the time it does not occur but when it does, I have no control over the cause - it seems to be dependent on time-of-run.

Does anyone know (a) what this error means and (b) how to stop it - note the "unauthorised" is strange because it displays this error DURING processing rather than at the start so is there some sort of token or authorisation which needs to be renewed or set to persist forever?

Very grateful for any help or advice,

Thanks,

- Seamus

  • GabB Profile Picture
    GabB 5 on at
    RE: The HTTP request is unauthorized with client authentication scheme 'Anonymous'.

    Hello Seamus , did the solution 1 and 2 resolved your issue? I am experiencing this issue as well. Thank you :)

  • Seamus Profile Picture
    Seamus 1,575 on at
    RE: The HTTP request is unauthorized with client authentication scheme 'Anonymous'.

    I am able to catch the error and recreate the crmserviceclient object but normal processing does not resume. Is there any way to check the authorisation token and renew it as necessary? The error seems to be occuring after about an hour.  This has never happened before - could it be something temporary at the Microsoft/server level? Many thanks for any advice.

  • Seamus Profile Picture
    Seamus 1,575 on at
    RE: The HTTP request is unauthorized with client authentication scheme 'Anonymous'.

    Thanks very much Guido for your helpful input. You are correct - it definitely is NOT consistent behaviour. I have done your suggestions 1&2 but will look at (3) - Thanks!

  • Verified answer
    Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: The HTTP request is unauthorized with client authentication scheme 'Anonymous'.

    in my experience there isn't always a root cause and I think that if you are using the .NET SDK the library should be always able to regenerate underline the required token without prompting that message.

    My suggested approach would be

    1) always update to the latest .NET SDK nuget packages (probably you already did that)

    2) use an azure app registration (maybe you are already using it but you didn't specify, in case you are still using username/password)

    3) implement inside your code a retry logic that recreate the CrmServiceClient object if you get an error or the IsReady property is returning false

    hope it helps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans