question

Upvotes
Accepted
33 1 1 4

Dex2 - The access to field(s) denied.

Hi, got error when trying dex2 examples. Everything is OK when using API from within Excel, but getting "The access to field(s) denied" error from Dex2 C# sample application. Why it happens? See the screenshot below.

eikoneikon-com-apiauthentication
dex2access.jpg (343.2 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
4.6k 26 7 22

You are trying to use the new set of fields (TR.<fieldname>) with the old initialisation routine. In order for this to work, you need to change the CreateDex2Mgr() initialisation routine.

Instead of:

MyDex2Cookie = MyDex2Mgr.Initialize();

You need to have:

MyDex2Cookie = (MyDex2Mgr as IDex2Mgr2).Initialize(DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN);
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
33 1 1 4

Yes, it works!

Спасибо :)

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
38 0 2 4

@Zhenya Kovalyov - Can you please post the new code for VB .NET as well (please also include changes to declarations etc if necessary)? I've modified the Dex2 VB .NET sample application for my own purposes but now ran across the same error. Thank you

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
4.6k 26 7 22

@vlscout

The correct initialisation routine for VB .NET will be the following:

 _dexCookie = DirectCast(_dexMgr, Dex2.IDex2Mgr2).Initialize(Dex2.DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN)

Full sample below:

Private _api As EikonDesktopDataAPILib.EikonDesktopDataAPI
Private _dexMgr As Dex2.Dex2Mgr
Private _dexCookie As Long
Private _rdata As Dex2.RData

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        _api = New EikonDesktopDataAPILib.EikonDesktopDataAPI
        AddHandler _api.OnStatusChanged, AddressOf Api_OnStatusChanged
        _api.Initialize()
End Sub

Private Sub Api_OnStatusChanged(ByVal eStatus As EikonDesktopDataAPILib.EEikonStatus)

        If eStatus = EikonDesktopDataAPILib.EEikonStatus.Connected Or eStatus = EikonDesktopDataAPILib.EEikonStatus.LocalMode Then

            _dexMgr = _api.CreateDex2Mgr()

            _dexCookie = DirectCast(_dexMgr, Dex2.IDex2Mgr2).Initialize(Dex2.DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN)

            _rdata = _dexMgr.CreateRData(_dexCookie)

            AddHandler _rdata.OnUpdate, AddressOf RData_OnUpdate

            With _rdata
                .InstrumentIDList = "TRI.TO"
                .FieldList = "TR.ISIN"
                .Subscribe(False)
            End With
        End If
End Sub

    Private Sub RData_OnUpdate(ByVal dataStatus As Dex2.DEX2_DataStatus, ByVal [error] As Object)

        Dim i As Long, j As Long

        For i = LBound(_rdata.Data, 1) To UBound(_rdata.Data, 1)
            For j = LBound(_rdata.Data, 2) To UBound(_rdata.Data, 2)
                Debug.Print(_rdata.Data(i, j))
            Next j
        Next i
End Sub
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thank you! It works.

Click below to post an Idea Post Idea