web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Mohamad Vajid Profile Picture
    on at
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: How to support BC15 on premise "UserName" Credential Type?

    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}");

  • Community Member Profile Picture
    on at
    RE: How to support BC15 on premise "UserName" Credential Type?

    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
    RE: How to support BC15 on premise "UserName" Credential Type?

    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).

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

Responsible AI policies

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

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,737 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,577

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,251

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans