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

Notifications

Announcements

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

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 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,166 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
    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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,810

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 810 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 676 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans