pythonworkfront-api

Python-workfront not able to retrieve values from search


So, I am creating a very simple search request using the python-workfront module to retrieve reference number for an issue.

issue = session.search(api.Issue,name='<<NAME>>',fields=['referenceNumber'])[0]

When I print the issue, it shows the associated value:

print(issue)

>', objCode='OPTASK', referenceNumber=1084233>

When I try and print just the reference number, I get the following error:

print(issue.referenceNumber)

File "", line 1, in runfile('C:/Python/Scripts/WorkFront_API_2.py', wdir='C:/Python/Scripts')

File "C:\app\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace)

File "C:\app\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Python/Scripts/WorkFront_API_2.py", line 31, in print(issue.referenceNumber)

AttributeError: 'Issue' object has no attribute 'referenceNumber'

I know this has to be something simple, but can't seem to figure it out...


Solution

  • If you refer to the documentation here, you'll see that the field referencenumber is accessed with the name reference_number. So in your example,

    print(issue.reference_Number)