I am trying to develop a python 3.9 program (that we plan to execute externally) that performs HTTP Get from the object structure related to person and displays the JSON returned from MAXIMO.
from pprint import pprint
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from urllib.parse import urlparse
import requests
import base64
from lblpycommon import lbl_libutil01
#-- ignore bad ssl
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
strObjectStructure="lbl_ds_person"
strAutomationScript=None
strListofColumns="personid,firstname,lastname,displayname,location,supervisor,lbl_status,lbl_org_level_1,lbl_org_level_2,lbl_org_level_3"
strWhere="lbl_org_level_1=%22IC%22"
strSavedQuery=None
# Get the MAXIMO URL from properties file
if (strAutomationScript==None):
strUrl=lbl_libutil01.getPropertyValue("maximorestoslcurl")+"/"+ strObjectStructure
else:
strUrl=lbl_libutil01.getPropertyValue("maximorestoslscriptcurl") +"/"+ strAutomationScript
# Prepare Headers
dictHeaders = {
#'maxauth': maxauth, # BASIC auth = login:passwd
'Accept': "application/json",
'Content-Type': "application/json",
'Allow-Hidden': "true",
}
# Prepare parameters
dictParams = {
'lean':1, # Remove name space - recomended when working with Maximo JSON
'oslc.select': 'personid,firstname,lastname,displayname,location,supervisor,lbl_status,lbl_org_level_1,lbl_org_level_2,lbl_org_level_3',
'oslc.where': "location='069-0102D'",
'oslc.pageSize':1,
'apikey':'*********'
}
r = requests.get(strUrl, headers=dictHeaders, params=dictParams, verify=False)
pprint(r.json())
==============================
My questions are ;
1) How to specify the "where clause" that contains something like location='069-0102D'. The line "
'oslc.where': "location='069-0102D'" gives error. I tried "location=%22069-0102D%22". However that is also not working.
2) For example ;
'oslc.where':'assetnum=Myasset111', -- it is not working. i tried "assetnum='%22Myasset111%22" etc.
also how to check for wildcard searches?
Also how to specify "or" "and" operators
For example:
'oslc.where':'assetnum=Myasset111
or location=90F
Appreciate any help.