ArcREST icon indicating copy to clipboard operation
ArcREST copied to clipboard

Having trouble updating a vector tile package and associated tile layer in AGOL

Open stdavis opened this issue 7 years ago • 5 comments

ArcRest or ArcRestHelper

arcrest

Version or date of download

3.5.6

Bug (likely in my code)

When trying to publish an update to an existing service I get the following error message:

Service already exist with the name ("StatewideParcels") of type ("VectorTileServer")
Traceback (most recent call last):
  File "update_agol_item.py", line 42, in <module>
    overwrite=True)
  File "C:\Python27\ArcGIS10.3\lib\site-packages\arcrest\manageorg\_content.py", line 2385, in publishItem
    raise Exception("Could not publish item: %s" % itemId)
Exception: Could not publish item: 40054ec45a144ca7a8ee13e298f845c6

Details

My goal is to write a script that can update a vector tile package item and its associated tile layer in AGOL. image

I think that I've got the updating of the tile package item working using item.updateItem but I'm having trouble updating the tile layer. I'm currently attempting to use user.publishItem. Here's my simple script:

import arcrest
from arcresthelper import securityhandlerhelper

securityinfo = {}
securityinfo['security_type'] = 'Portal'  # LDAP, NTLM, OAuth, Portal, PKI
securityinfo['username'] = '<name>'
securityinfo['password'] = '<password>'
securityinfo['org_url'] = 'http://utah.maps.arcgis.com'

itemId = '40054ec45a144ca7a8ee13e298f845c6'
upload_file = r'C:\Temp\StatewideParcels.vtpk'

shh = securityhandlerhelper.securityhandlerhelper(securityinfo)
if shh.valid is False:
    print(shh.message)
else:
    portalAdmin = arcrest.manageorg.Administration(securityHandler=shh.securityhandler)
    item = portalAdmin.content.getItem(itemId=itemId).userItem

    itemParams = arcrest.manageorg.ItemParameter()

    itemParams.overwrite = True
    itemParams.type = 'Vector Tile Package'
    itemParams.title = 'Utah Statewide Parcels Test3'

    print('uploading...')
    res = item.updateItem(itemParameters=itemParams,
                          data=upload_file,
                          multipart=True)

    print(res)

    print('publishing...')
    user = portalAdmin.content.users.user()
    publishParams = arcrest.manageorg.ItemParameter()
    publishParams.overwrite = True

    res = user.publishItem(fileType='tilePackage',
                           publishParameters=publishParams,
                           itemId=itemId,
                           wait=True,
                           overwrite=True)
    print(res)

Can anyone help me know what I'm doing wrong?

Thanks in advance.

stdavis avatar Sep 30 '16 13:09 stdavis

Is there anyone out there that can point me in the right direction?

stdavis avatar Oct 17 '16 13:10 stdavis

When troubleshooting a process, I use fiddler to watch the traffic and do the task manually, then compare that to what ArcRest is doing and find the difference. Could you provide us what is different so we can isolate the issue?

MikeMillerGIS avatar Oct 17 '16 16:10 MikeMillerGIS

@MikeMillerGIS: Sure, I can do that. So are you inferring that my approach in my code is correct and that it should be working?

stdavis avatar Oct 18 '16 13:10 stdavis

It appears to be, what is the res message from update item?

MikeMillerGIS avatar Oct 18 '16 14:10 MikeMillerGIS

{
    "item": {
        "itemType": "file",
        "culture": "en-us",
        "owner": "u0281276",
        "guid": "E54D5F2F-F199-4FFD-B182-41D8EB3DD6A7",
        "screenshots": [],
        "id": "cde49aec1411473e9bb8b9af07e0dd21",
        "size": 3343703,
        "appCategories": [],
        "access": "private",
        "avgRating": 0,
        "title": "Parcels Test",
        "numRatings": 0,
        "numComments": 0,
        "snippet": "Layers",
        "listed": false,
        "largeThumbnail": null,
        "itemControl": "admin",
        "type": "Vector Tile Package",
        "thumbnail": "thumbnail/thumbnail.png",
        "uploaded": 1475253247000,
        "industries": [],
        "numViews": 0,
        "description": "<DIV STYLE=\"text-align:Left;font-size:12pt\"><P><SPAN>Concatenation of parcels data from all 29 counties within the state of Utah.</SPAN></P></DIV>",
        "tags": ["keyword", "Data", "Vector Tile Package", "vtpk"],
        "typeKeywords": ["ArcGIS Pro", "Data", "Vector Tile Package", "vtpk"],
        "extent": [
            [-116.699604119079, 36.6922467095846],
            [-106.476088094695, 42.2818695075224]
        ],
        "banner": null,
        "properties": null,
        "name": "ParcelsTest",
        "licenseInfo": null,
        "languages": [],
        "url": null,
        "lastModified": -1,
        "documentation": null,
        "modified": 1476811229000,
        "spatialReference": "WGS_1984_Web_Mercator_Auxiliary_Sphere",
        "item": "ParcelsTest.vtpk",
        "protected": false,
        "ownerFolder": null,
        "accessInformation": null
    },
    "sharing": {
        "access": "private",
        "groups": []
    }
}

stdavis avatar Oct 18 '16 17:10 stdavis