Menu

#24 ars.GetEntry('BMC.CORE:BMC_ComputerSystem..) does not work

v1.0_(example)
accepted
Ergorion
None
1
2017-06-17
2017-06-13
Anonymous
No

Below code gives me error

import sys
import logging
from pyars import cars, erars, ars

ars = erars.erARS()

ars.Login('someserver1:2001', 'user', 'password') # login to the server

ars.logger.setLevel(logging.DEBUG)

entry = ars.GetEntry('BMC.CORE:BMC_ComputerSystem',{'AssetIDLowerCase':'abcd'},None)

if(not(entry is None)):
    for fieldid in entry.keys():
        print '%d: %s' % (fieldid, entry[fieldid])
ars.Logoff()

Error

Traceback (most recent call last):
  File "cmdb.py", line 11, in <module>
    entry = ars.GetEntry('BMC.CORE:BMC_ComputerSystem',{'AssetIDLowerCase':'abcd'},None)
  File "D:\sandbox\pyars-Test\py27_env\lib\site-packages\pyars\erars.py", line 1588, in GetEnt
ry
    entryId = self.conv2EntryIdList(schemaString, entry)
  File "D:\sandbox\pyars-Test\py27_env\lib\site-packages\pyars\erars.py", line 237, in conv2En
tryIdList
    entrylist = createSchemaIdList(schemaString, entry)
  File "D:\sandbox\pyars-Test\py27_env\lib\site-packages\pyars\erars.py", line 165, in createS
chemaIdList
    return ((schemaString, entry[0]), )
KeyError: 0

Discussion

  • Ergorion

    Ergorion - 2017-06-17
    • status: open --> accepted
     
  • Ergorion

    Ergorion - 2017-06-17

    What are you trying to achieve?
    ars.GetEntry expectes to receive the name of a form and an entryid.
    If you want to retrieve specific entries (e.g. using a query), you need to use ars.GetListEntryWithFields.
    Please have a look at the tutorial (http://pyars.sourceforge.net/tutorial.html) which tries to explain the most common use cases and how to implement them.

    Hope this helps,
    Axel

     

Anonymous
Anonymous

Add attachments
Cancel