Article ID: 116401, created on Jul 8, 2013, last review on Oct 28, 2014

  • Applies to:
  • Business Automation 5.4

Retrieve extended account attributes using PBA API

Python is a powerful language that includes all tools required to interface with the PBA API. The following PBA 5.4 API example retrieves four custom attributes from an account if available. This generic approach can be used on any extended attribute.

All information about available methods in PBA public API, could be found in documentation: Public API Reference

Below you could find example of AccountDetailsGet_API method:

The line

server = xmlrpclib.ServerProxy('http://192.168.234.45:5224/RPC2')

defines the location of the PBA server. By default, it listens on port 5224. You need to make sure that this port is reachable from your source IP. Replace 198.168.234.45 with the correct IP address of your server.

import xmlrpclib
import base64
import sys

try:
   customer = input("Enter Parallels customer account number: ")
except Exception:
   print "No customer account entered"
   sys.exit(1);

server = xmlrpclib.ServerProxy('http://192.168.234.45:5224/RPC2')

p1 = {"Server":"BM","Method":"AccountDetailsGet_API","Params":[customer]}

try:
   Customer = (server.Execute(p1))
except Exception, err:
   print 'Fault code:', err.faultCode
   print 'Message :', base64.b64decode(err.faultString)
   sys.exit(2)

print "Customer: " , Customer['Result'][0][0]
print "Account: " , Customer['Result'][0][2]

p2 = {"Server":"BM", "Method":"GetObjAttrList_API","Params":[0,customer,0,""]}

try:
   Customer = (server.Execute(p2))
except Exception, err:
   print 'Fault code:', err.faultCode
   print 'Message :', base64.b64decode(err.faultString)
   sys.exit(3)

if Customer['Result'][0][1][1] :
   print "CPF: " , Customer['Result'][0][1][1]
if Customer['Result'][0][0][1] :
   print "CPNJ: ", Customer['Result'][0][0][1]
if Customer['Result'][0][4][1] :
   print "CLE: ", Customer['Result'][0][4][1]

# CPNJ: ['CPF', '585.816.358-06', 'PERS']
# {'Result': [[['CNPJ', '', 'COMP'], ['CPF', '585.816.358-06', 'PERS'], ['Complemento', '', 'COMP, PERS'], ['Bairro', 'wswsw', 'COMP, PERS'], ['CLE', '000000023232323', 'PERS, COMP']]]}

Resulting in output:

[root@pbalinfe01 parallels]# python retracct.py
Enter Parallels customer account number: 1000010
Customer: 1000010
Account: QATestCSD
CPF: 1
CPNJ: 113045999
CLE: 0
[root@pbalinfe01 parallels]#

Search Words

Python PBA API example

210d017ddc3a076d22f0f865b1cf0730 caea8340e2d186a540518d08602aa065 198398b282069eaf2d94a6af87dcb3ff 92711db0799e8aefe8e51f12dace0496 e12cea1d47a3125d335d68e6d4e15e07

Email subscription for changes to this article
Save as PDF