Select to view content in your preferred language

Hosted Feature layer notifications

4086
24
04-13-2023 11:58 AM
Labels (2)
SLouq
by MVP Alum
MVP Alum

I have workers in the field doing hydrant inspections using Survey123. When they submit the form, it updates a hosted feature layer which I can access in my ArcGIS Pro document. I was wondering since I update a hydrant feature class with the information they are publishing in the hosted feature layer, is there a way for me to get a notification whenever that hosted feature layer is updated? Instead of me just having to remember to check it everyday to see if it's been updated.

Thanks

0 Kudos
24 Replies
SLouq
by MVP Alum
MVP Alum

I'm not sure how to direct message on here and I don't want to share the init.json file since it has our email servere info in it.  So I'll just post questions if that's ok.

for the fsURL in the init.json file I have the URL of the Hosted Feature Layer.

SLouq_0-1682013201608.png

Is this the correct URL for the fsURL?

When I copy and paste that URL into my web browser it goes to an ARCGIS REST service directory but it says Token Required

SLouq_0-1682015059519.png

 

To answer your question, Yes the init.json file is in the same folder as the DetectChanges.py file.

SLouq_0-1682014223020.png

It is generating a folder called 'generations' but it is empty

0 Kudos
SLouq
by MVP Alum
MVP Alum

The only question I have about the python script is for the line that says

if servername=="smtp.gmail.com":
server.login(srvrInfo[2],srvrInfo[3])

Does the servername need to be my 'organization's smtp server name' and not smtp.gmail.com?

0 Kudos
RhettZufelt
MVP Notable Contributor

You should not make any changes to the python script, just the init.json file.

Yes, that is the correct URL to put in there, but, the HFS will also have at least one layer in it.  This script monitors for changes in a layer in the HFS, so you need to supply the layer number for the fsLayerNum: in the json file.  Here is my file with sensitive info changed:

RhettZufelt_0-1682016177115.png

I use internal mail server, with no issues (set in the "email" portion of the json file "server": ).

Once it runs correctly, or at least creates the layergens file, you will see that file appear in the 'generations' folder.  AND, if you make any changes to the init.json after running it, you will need to delete the layergens file that gets created there or you may get errors.  (it is specific for the single layer from the HFS that is configured in the init.json)

the "serviceuser": and "servicepw" need to be a user that has access to that service. 

However, based on the last error message you provided, I don't think it is getting that far.  Seems there is something wrong with the init.json file.

In python window, you should be able to put the following code:

import os
import json
os.chdir(r'C:\CD')
cfile = 'init.json'
json.load(open(cfile))

That should print the contents of the init.json file as a json string.  If it doesn't, or errors out, this is where the problem lies.  Once you get past that, will be easier to troubleshoot (if needed).

R_

 

 

0 Kudos
SLouq
by MVP Alum
MVP Alum

I made a copy of the init.json file for you to look at and edited out the sensitive information. 

I left the fsLayerNum value set to 0 because that is what it shows in the service URL when I view it. 

Here is the init.json file

SLouq_0-1682018116744.png

 

0 Kudos
RhettZufelt
MVP Notable Contributor

Are you using your internal smtp server and just changed to gmail as that is sensitive?  I ask, as there are specific instructions in the original post of how to configure if using gmail.

Other than that, I see you have serviceuser and servicepw in the init.json set to an email, and smtp.

This needs to be the AGOL username and password that has access to the service (otherwise, token errors).

Also, the serviceuser does not have quotes around it, which causes it to throw the exact error of you earlier post (why it is not parsing the json correctly).

RhettZufelt_0-1682019486375.png

R_

 

0 Kudos
SLouq
by MVP Alum
MVP Alum

yes I changed it to smtp

0 Kudos
SLouq
by MVP Alum
MVP Alum

I think I am missing something from the fsURL. 

When I copy and paste that URL into a web browser, it goes to this page

 

SLouq_0-1682019888044.png

but when I click on view from the HFS overview page, it goes to the FS REST Service Directory

SLouq_1-1682019994505.png

 

0 Kudos
RhettZufelt
MVP Notable Contributor

After your second example, right click on the >service_...... at the top and open in new window/tab.

RhettZufelt_0-1682020317789.png

 

R_

0 Kudos
SLouq
by MVP Alum
MVP Alum

Should I copy that URL for the fsURL in the init.json file?

0 Kudos
SLouq
by MVP Alum
MVP Alum

It adds a tokenID to the URL

0 Kudos