Python script to Add PDF to My Content

1541
2
Jump to solution
07-23-2018 08:14 AM
DrewMerrill1
New Contributor III

Hello,

I would like the ability to add or update a non-spatial item like a pdf from my computer to My Content in AGOL through a python script.  We have an agol organizational account, but not arcgis enterprise.  Does anyone know if this is possible?

 Jake Skinner 

Tags (2)
1 Solution

Accepted Solutions
AndrewValenski__IT_
Occasional Contributor III

The following code snippet worked for me:

from IPython.display import display
from arcgis.gis import GIS
import os
gis = GIS("https://www.arcgis.com", "MyUsername", "MyPassword")

pdfdata = "C:\\SomePath\\SomeFolder\\SomeFile.pdf"

pdfprop = {'title':'something','description':'this is a thing','tags':'tag','type':'PDF'}

pdf Doc = gis.content.add(item_properties = pdfprop , data = pdfdata)

View solution in original post

2 Replies
AndrewValenski__IT_
Occasional Contributor III

The following code snippet worked for me:

from IPython.display import display
from arcgis.gis import GIS
import os
gis = GIS("https://www.arcgis.com", "MyUsername", "MyPassword")

pdfdata = "C:\\SomePath\\SomeFolder\\SomeFile.pdf"

pdfprop = {'title':'something','description':'this is a thing','tags':'tag','type':'PDF'}

pdf Doc = gis.content.add(item_properties = pdfprop , data = pdfdata)
vonmoosa
MVP

I used this same script to upload a kml file but noticed when I do so it does not generate a Data Source URL in the item properties. Any ideas?

0 Kudos