Welcome Guest | Join Now! | Help | Sign in
Site Search:

401 Unautorized error: ReadMultiple method of web service

401 Unautorized error: ReadMultiple method of web service

Not Answered This question is not answered

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 (at the bottom of the post) to read and list the Fixed Assets.

I am using the SQL sa credentials to connect to the web service, which has been created in NAV as a database user.

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?

 

Dim AssetWS As New NAVFixedAsset.FixedAsset_Service

AssetWS.UseDefaultCredentials = False

AssetWS.Credentials = New Net.NetworkCredential("sa", "password")

Dim FixedAssets() As NAVFixedAsset.FixedAsset

FixedAssets = AssetWS.ReadMultiple(New NAVFixedAsset.FixedAsset_Filter() {}, Nothing, 0)

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

dt.Rows.Add(dr)

Next

Dim dv As DataView = New DataView(dt)

dlstAsset.DataSource = dv

dlstAsset.DataBind()

All Replies
Page 1 of 1 (7 items)