web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

How to support BC15 on premise "UserName" Credential Type?

(0) ShareShare
ReportReport
Posted on by

Does anybody know BC15 onpremise "UserName" credential type use which scheme to connect BC using httpclient?

 

For the "UserNavPassword" credential type, the scheme is "Basic", but I hardly to find about "UserName".

below is my connect code:

try
{
CredentialCache CCatch = new CredentialCache();
CCatch.Add(new Uri("">bc.sunshinemills.com/.../SignIn, "Negotiate", new NetworkCredential("test", "test"));
HttpClientHandler Handler = new HttpClientHandler();
Handler.UseCookies = true;
Handler.CookieContainer = new CookieContainer();
Handler.Credentials = CCatch;
Client = new HttpClient(Handler);
Client.DefaultRequestHeaders.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json"));
HttpResponseMessage response = Client.GetAsync("URL").Result;
// LogTrace(response.StatusCode.ToString());
string sResponseConent = response.Content.ReadAsStringAsync().Result;
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
if (Client != null)
Client = null;
}

 

Thanks,

Ming

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    Username is the name of your user as show in User page. The password is the web service access key for the user (created on the User card page).

  • Community Member Profile Picture
    on at

    Thanks for your reply, could you please shed me some lights on how to authenticate UserName credential type through C# code?

    Thanks again.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    To authenticate on D365BC APIs, you can do something like:

    HttpClient client = new HttpClient();

    string userAndPasswordToken =

                   Convert.ToBase64String(Encoding.UTF8.GetBytes(user + ":" + wsaccesskey));

               client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization",

                   $"Basic {userAndPasswordToken}");

  • Mohamad Vajid Profile Picture
    Microsoft Employee on at

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 750 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 534 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 287 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans