401 Unauthorized error: ReadMultiple method of web service

I have created a simple Page web service on the Fixed Asset table as I want to read the Fixed Assets in NAV in another web application. I have created and published the web service in NAV and can access it from a browser. I have added a web reference to my web application (which uses forms-based authentication) and I have the following code to read and list the Fixed Assets:

Dim AssetWS As New NavFixedAsset.FixedAsset_Service

AssetWS.UseDefaultCredentials = False

AssetWS.Credentials = New Net.NetworkCredentials(“sa”,“password”)

Dim dt As DataTable = New DataTable

Dim dr As DataRow

dt.Columns.Add(New DataColumn(“No”, Type.GetType(“String”)))

dt.Columns.Add(New DataColumn(“AssetReg”, Type.GetType(“String”)))

dt.Columns.Add(New DataColumn(“Description”, Type.GetType(“String”)))

dt.Columns.Add(New DataColumn(“FALocationCode”, Type.GetType(“String”)))

dt.Columns.Add(New DataColumn(“SerialNo”, Type.GetType(“String”)))

For Each FixedAsset As NAVFixedAsset.FixedAsset In FixedAssets

dr = dt.NewRow

dr(0) = FixedAsset.No

dr(1) = FixedAsset.Asset_Reg

dr(2) = FixedAsset.Description

dr(3) = FixedAsset.FA_Location_Code

dr(4) = FixedAsset.Serial_No



Dim dv As DataView = New DataView(dt)

DataList.DataSource = dv


The sa username is created in NAV as a database user, and the credentials being passed are correct.

The error is “The request failed with HTTP status 401: Unauthorized.” and it seems to be thrown when the ReadMultiple method is called. I have tried with UseDefaultCredentials = True but then the machine name is passed (eg. DOMAIN\COMPUTER$) which is not a valid user in the NAV database.

Can anyone advise how this should work please?

Webservice/service tier only work with windows authentication.

hi Rashed Amini

we can also send username and password manually this is as per my info .

what is your opinion?

yes you can send them, but they have to be windows users. AssetWS.Credentials = New Net.NetworkCredentials(“sa”,“password”)