<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic MakeTableView not working with Secured Service in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/maketableview-not-working-with-secured-service/m-p/1496716#M70910</link>
    <description>&lt;P&gt;I have a bit of code that is making a Table View and then updating a field based on a WHERE clause.&lt;/P&gt;&lt;P&gt;as Long as my Service is PUBLIC it works fine... if I lock down to Organization or Owner it does not work.&amp;nbsp; I am using a TOKEN but that still does not work...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting an error that the table view does not exist which is telling me the&amp;nbsp;arcpy.management.MakeTableView is not working on the secured service.&lt;/P&gt;&lt;P&gt;Why does this not work on a Secured Service with a proper TOKEN&lt;/P&gt;&lt;LI-CODE lang="c"&gt;def updateDataFlagValuesToImported():
    gis2 = GIS("https://**unspecified**.com/portal", "username", "********")
    currenttoken2 = gis2._con.token
    print(currenttoken2)
    arcpy.env.overwriteOutput = True
    updateFlagURL = r"https://**unspecified**.com/env/rest/services/**unspecified**/FeatureServer/0?token=" + currenttoken2
    print(updateFlagURL)
    whereClause = "FLAG IS NULL"
    tableView = "fLyr"
    try:
        arcpy.management.MakeTableView(updateFlagURL, tableView, whereClause)
    except Exception:
        # Handle errors accordingly...this is generic
        tb = sys.exc_info()[2]
        tb_info = traceback.format_tb(tb)[0]
        pymsg = 'PYTHON ERRORS:\n\tTraceback info:\t{tb_info}\n\tError Info:\t{str(sys.exc_info()[1])}\n'
        msgs = 'ArcPy ERRORS:\t{arcpy.GetMessages(2)}\n'
        print(pymsg)
        print(msgs)
        
    arcpy.management.CalculateField(
        in_table= "fLyr",
        field="FLAG",
        expression="'Imported'",
        expression_type="PYTHON3",
        code_block="",
        field_type="TEXT",
        enforce_domains="NO_ENFORCE_DOMAINS"
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jun 2024 16:05:42 GMT</pubDate>
    <dc:creator>kapalczynski</dc:creator>
    <dc:date>2024-06-24T16:05:42Z</dc:date>
    <item>
      <title>MakeTableView not working with Secured Service</title>
      <link>https://community.esri.com/t5/python-questions/maketableview-not-working-with-secured-service/m-p/1496716#M70910</link>
      <description>&lt;P&gt;I have a bit of code that is making a Table View and then updating a field based on a WHERE clause.&lt;/P&gt;&lt;P&gt;as Long as my Service is PUBLIC it works fine... if I lock down to Organization or Owner it does not work.&amp;nbsp; I am using a TOKEN but that still does not work...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting an error that the table view does not exist which is telling me the&amp;nbsp;arcpy.management.MakeTableView is not working on the secured service.&lt;/P&gt;&lt;P&gt;Why does this not work on a Secured Service with a proper TOKEN&lt;/P&gt;&lt;LI-CODE lang="c"&gt;def updateDataFlagValuesToImported():
    gis2 = GIS("https://**unspecified**.com/portal", "username", "********")
    currenttoken2 = gis2._con.token
    print(currenttoken2)
    arcpy.env.overwriteOutput = True
    updateFlagURL = r"https://**unspecified**.com/env/rest/services/**unspecified**/FeatureServer/0?token=" + currenttoken2
    print(updateFlagURL)
    whereClause = "FLAG IS NULL"
    tableView = "fLyr"
    try:
        arcpy.management.MakeTableView(updateFlagURL, tableView, whereClause)
    except Exception:
        # Handle errors accordingly...this is generic
        tb = sys.exc_info()[2]
        tb_info = traceback.format_tb(tb)[0]
        pymsg = 'PYTHON ERRORS:\n\tTraceback info:\t{tb_info}\n\tError Info:\t{str(sys.exc_info()[1])}\n'
        msgs = 'ArcPy ERRORS:\t{arcpy.GetMessages(2)}\n'
        print(pymsg)
        print(msgs)
        
    arcpy.management.CalculateField(
        in_table= "fLyr",
        field="FLAG",
        expression="'Imported'",
        expression_type="PYTHON3",
        code_block="",
        field_type="TEXT",
        enforce_domains="NO_ENFORCE_DOMAINS"
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 16:05:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/maketableview-not-working-with-secured-service/m-p/1496716#M70910</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2024-06-24T16:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: MakeTableView not working with Secured Service</title>
      <link>https://community.esri.com/t5/python-questions/maketableview-not-working-with-secured-service/m-p/1496727#M70911</link>
      <description>&lt;P&gt;Think I just got it... I added the line to sign into Portal and I think its working...&amp;nbsp;&lt;BR /&gt;I also removed the TOKEN which was not needed on the Service... the portal login was enough&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;portalURL = 'https://**unspecified**.com/portal'
username = 'username'
password = '********'

arcpy.SignInToPortal(portalURL, username, password)

def updateDataFlagValuesToImported():
    updateFlagURL = r"https://**unspecified**.com/env/rest/services/**unspecified**/FeatureServer/0"
    whereClause = "FLAG IS NULL"
    tableView = "fLyr"

    arcpy.management.MakeTableView(updateFlagURL, tableView, whereClause)

    arcpy.management.CalculateField(
        in_table= "fLyr",
        field="FLAG",
        expression="'Imported'",
        expression_type="PYTHON3",
        code_block="",
        field_type="TEXT",
        enforce_domains="NO_ENFORCE_DOMAINS"
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 16:21:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/maketableview-not-working-with-secured-service/m-p/1496727#M70911</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2024-06-24T16:21:25Z</dc:date>
    </item>
  </channel>
</rss>

