AnsweredAssumed Answered

gis.content.search() parameter substitution

Question asked by CW0159@mt.gov_montana on Aug 9, 2018
Latest reply on Aug 9, 2018 by CW0159@mt.gov_montana

Greetings,

 

I am using the ArcGIS API for Python and I am struggling with passing parameters to the gis.content.search function.

 

  1. If I type in command parameters  and run the snippet temp_list  =  gis.content.search(query="Boundaries AND owner:MontanaStateLibrary) a list of content is returned. 
  2. However if I build a string, st = 'query=' + '"' + 'Boundaries AND owner:MontanaStateLibrary' + '"',  and do something like this: temp_list  =  gis.content.search(st) an empty list is returned.
    1. In troubleshooting I have copied the printed string, st,  from the interactive window and pasted the text into the gis.content.search()  command which results in a list of content.
  3. As of right now the following code is just a brain dump.  I am using 2 lists to build the parameter string.

     

     

    try:
    query_list = ['Boundaries', 'ConservationEasements', 'Geographic Names', 'Hydrography', 'LandCover', 'Mapping Control', 'MontanaMask', 'Montana Managed Areas', 'Montana NAIP', 'NAIP', 'Parcel', 'PLSSS', 'PublicLands', 'Roads', 'Structures', 'Watershed', 'Wetlands']

    item_type_list = list()
    st = 'item_type =' + '"' + 'Feature Layer' + '"'
    item_type_list.append(st)
    st = 'item_type =' + '"' + 'Imagery Layer'# + '"'
    item_type_list.append(st)
    st = 'item_type =' + '"' + 'Map Image Layer'# + '"'
    item_type_list.append(st)
    for q in query_list:
    st = 'query=' + '"' + q + ' AND owner:MontanaStateLibrary' + '"' #+ ', '
    temp_list = gis.content.search(st)

     

 

 

Am I missing something obvious?

 

 

arcgis-api-python

Outcomes