How to set Basic Authentication in C# ASP.NET (NavUserPassword) - Consuming Business Central On-Premise SOAP URL

Hello everyone,

Lately, I’ve been working on a web application that consumes Business Central APIs. (from a SOAP URL)

The code that I wrote worked just fine before changing the Credential Type from Windows to NavUserPassword (in order to consume APIs with Basic authorization)

But then, (after I changed to NavUserPassword) it started given me a server error (HTTP status 401: Unauthorized)

I did some research about how to set username and password in a header property or something and I found some solutions but none of them worked for me,

Can anyone help me solve this please

Thanks.

Idk if this would work for you. This is a snippet out of one of my C# apps that syncs data from an external program to NAV2017

This uses the NetworkCredentials and a u/p that is passed to it.