nzjs / Automated-Survey123-Reports

A tool to automate Survey123 Report creation & emailing survey recipients with a copy of the report.
21 stars 7 forks source link

Error with featureLayerUrl #1

Closed jvarasanz closed 3 years ago

jvarasanz commented 5 years ago

Thanks a lot for this post.

I’m trying to use this code but keep getting the following error:

File "C:/Users/.../PycharmProjects/AGOLPRO/Survey123 API Access.py", line 77, in survey.generate_report(template, querySurvey123)

File "C:\Users...\AGOLPRO\lib\site-packages\arcgis\apps\survey123_survey.py", line 227, in generate_report "featureLayerUrl" : self._ssi.layers[0]._url.replace("_fieldworker", ""), AttributeError: 'NoneType' object has no attribute 'layers'

Not sure if this makes sense, but I don’t have a layer or rest end point containing “fieldworker”.

Please advise.

nzjs commented 5 years ago

@jvarasanz Can you answer a couple questions for me:

  1. Have you modified the AGOL information and Survey123 variables in the code? (org, username, password, surveyID)
  2. Does the AGOL user in the variables have permissions to access the Survey data? Note that I have it working with a user account that is the owner of my survey.
  3. Can you share the txt log file so we can see how far the script gets?
jvarasanz commented 5 years ago

Answers below:

  1. AGOL information updated and pointing to the correct survey

  2. AGOL user has permission to access the survey’s data. I created this user for testing purposes, but can try with the owner. I’ll back with you on this tomorrow.

  3. I’m not using your txt log file logic, but have a logger running. I’ll send you a complete log tomorrow as well. However, it does stop right after the request to generate the report is submitted.

Thanks a lot for your assistance.

From: John notifications@github.com Sent: Thursday, April 11, 2019 4:53 PM To: nzjs/Automated-Survey123-Reports Automated-Survey123-Reports@noreply.github.com Cc: Vara, Javier jvara@tfs.tamu.edu; Mention mention@noreply.github.com Subject: Re: [nzjs/Automated-Survey123-Reports] Error with featureLayerUrl (#1)

@jvarasanzhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jvarasanz&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=H10LpLRgghF7jb8LqA8AQg8JcM6hk0OiE8wUCejqM_I&s=NP8Fd9ojqB5PDkdgJInDVimp3EgIojImVk3cmvQcB6M&e= Can you answer a couple questions for me:

  1. Have you modified the AGOL information and Survey123 variables in the code? (org, username, password, surveyID)
  2. Does the AGOL user in the variables have permissions to access the Survey data? Note that I have it working with a user account that is the owner of my survey.
  3. Can you share the txt log file so we can see how far the script gets?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nzjs_Automated-2DSurvey123-2DReports_issues_1-23issuecomment-2D482335269&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=H10LpLRgghF7jb8LqA8AQg8JcM6hk0OiE8wUCejqM_I&s=He4djUR_sKjSHTKxjhzti5lhgEiUO3AanSr6uGABCGc&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AvPfaEEGGN2j5TWL2GA4ZYVSdFrh14u4ks5vf67DgaJpZM4cq1p7&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=H10LpLRgghF7jb8LqA8AQg8JcM6hk0OiE8wUCejqM_I&s=jgUyDzXfHbS1v8Qp16cS__h2-TgaW7y3KPVU8y3mA94&e=.

nzjs commented 5 years ago

Couple other things that I can maybe see an issue with:

The report_template variable is set to 1 in my example script. This is pointing to the second report template in the Survey123 Reports tab. Do you have two report templates or only one? If you only have one, this should be set to 0.

Is this your code in Survey123 API Access.py? survey.generate_report(template, querySurvey123) If so, I would try also adding utc_offset and report_title parameters as mentioned in the API docs.

I know they are optional but the remainder of my script depends on report_title existing to generate the reports and host them in the online space. https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.apps.survey123.html#arcgis.apps.survey123.Survey.generate_report

jvarasanz commented 5 years ago

Good morning John.

Back with you. It’s been a loooooong day.

I only had one report template, so the report_template variable is set to 0. FYI, I had a print statement to confirm the report template and that is correct.

In regards to my code…. survey.generate_report(template, querySurvey123)… I am not setting any parameters for utc_offset and report_title. At this point I’m not using any more of your code, since I’m just checking if the report will generate first.

By the way, ESRI reply to a similar request with the following:

Are you using the Feature Report API as documented in Survey123 EAC site: https://earlyadopter.esri.com/project/article/item.html?cap=e69ef91f45744b98882c651f7b518eb7&arttypeid={5a8e51ed-4a87-43fe-a67d-2b7829af130f}&artid={0ECA95A6-000C-4C27-B062-8CC9DF44569E}https://urldefense.proofpoint.com/v2/url?u=https-3A__community.esri.com_external-2Dlink.jspa-3Furl-3Dhttps-253A-252F-252Fearlyadopter.esri.com-252Fproject-252Farticle-252Fitem.html-253Fcap-253De69ef91f45744b98882c651f7b518eb7-2526arttypeid-253D-257B5a8e51ed-2D4a87-2D43fe-2Da67d-2D2b7829af130f-257D-2526artid-253D-257B0ECA95A6-2D000C-2D4C27-2DB062-2D8CC9DF44569E-257D&d=DwMCaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=OX4BIqLK2INgmrO3qle5ANDH0pQYgsN5g4uFDih9xYs&s=1W_xeZkwQeQkFKy6cr0hSeZk9KGNVPJA4GH-wrrpvGg&e=

If so this is a beta feature currently and you should raise any issues related to this in the EAC forum. It looks like they might have a bug.

I honestly believe there is nothing wrong with your code, but more with the ESRI code for _survey.py, which for some reason is trying to find a layer ending in “_fieldworker”, which is only generated when providing access to the data in web forms. This is all I can think about.

Let me know if you come out with any other ideas. Thanks a lot for your time. Javier

From: John notifications@github.com Sent: Thursday, April 11, 2019 5:07 PM To: nzjs/Automated-Survey123-Reports Automated-Survey123-Reports@noreply.github.com Cc: Vara, Javier jvara@tfs.tamu.edu; Mention mention@noreply.github.com Subject: Re: [nzjs/Automated-Survey123-Reports] Error with featureLayerUrl (#1)

Couple other things that I can maybe see an issue with:

The report_template variable is set to 1 in my example script. This is pointing to the second report template in the Survey123 Reports tab. Do you have two report templates or only one? If you only have one, this should be set to 0.

Is this your code in Survey123 API Access.py? survey.generate_report(template, querySurvey123) If so, I would try also adding utc_offset and report_title parameters as mentioned in the API docs.

I know they are optional but the remainder of my script depends on report_title existing to generate the reports and host them in the online space. https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.apps.survey123.html#arcgis.apps.survey123.Survey.generate_reporthttps://urldefense.proofpoint.com/v2/url?u=https-3A__esri.github.io_arcgis-2Dpython-2Dapi_apidoc_html_arcgis.apps.survey123.html-23arcgis.apps.survey123.Survey.generate-5Freport&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=elRSK8WZkJ3B4-PdcKAbKCalctHxbO31X_YOKK-Dm7k&s=kg2Vxfr_LMt3x6n8mlWGUCSE-70dkE3jtYtoVVtZIos&e=

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nzjs_Automated-2DSurvey123-2DReports_issues_1-23issuecomment-2D482341505&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=elRSK8WZkJ3B4-PdcKAbKCalctHxbO31X_YOKK-Dm7k&s=ZYGyTmHcosHcSCtstc_S_VSajqkbfcBSqk-UwOtjkck&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AvPfaDEI38MmGPVzNB8S57pitn-2DGze9qks5vf7HngaJpZM4cq1p7&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=elRSK8WZkJ3B4-PdcKAbKCalctHxbO31X_YOKK-Dm7k&s=k4grmUgoGqxP0c76XazwEx3YDmkx8gGFugg6Kj-Z464&e=.

nzjs commented 5 years ago

Thanks for your reply, that's really interesting.

Yes this is using the beta version of the API. I'll take a look at that when back in the office.

Another difference could be that my survey was created with the S123 Connect app rather than the web based editor? So my particular survey does have the _fieldworker and _stakeholder layers associated with it.

You could try publishing a new survey via the Connect app and try again. Interested to hear if that works.

Get Outlook for Androidhttps://aka.ms/ghei36


From: jvarasanz notifications@github.com Sent: Saturday, April 13, 2019 9:38:32 AM To: nzjs/Automated-Survey123-Reports Cc: John; Comment Subject: Re: [nzjs/Automated-Survey123-Reports] Error with featureLayerUrl (#1)

Good morning John.

Back with you. It’s been a loooooong day.

I only had one report template, so the report_template variable is set to 0. FYI, I had a print statement to confirm the report template and that is correct.

In regards to my code…. survey.generate_report(template, querySurvey123)… I am not setting any parameters for utc_offset and report_title. At this point I’m not using any more of your code, since I’m just checking if the report will generate first.

By the way, ESRI reply to a similar request with the following:

Are you using the Feature Report API as documented in Survey123 EAC site: https://earlyadopter.esri.com/project/article/item.html?cap=e69ef91f45744b98882c651f7b518eb7&arttypeid={5a8e51ed-4a87-43fe-a67d-2b7829af130f}&artid={0ECA95A6-000C-4C27-B062-8CC9DF44569E}https://urldefense.proofpoint.com/v2/url?u=https-3A__community.esri.com_external-2Dlink.jspa-3Furl-3Dhttps-253A-252F-252Fearlyadopter.esri.com-252Fproject-252Farticle-252Fitem.html-253Fcap-253De69ef91f45744b98882c651f7b518eb7-2526arttypeid-253D-257B5a8e51ed-2D4a87-2D43fe-2Da67d-2D2b7829af130f-257D-2526artid-253D-257B0ECA95A6-2D000C-2D4C27-2DB062-2D8CC9DF44569E-257D&d=DwMCaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=OX4BIqLK2INgmrO3qle5ANDH0pQYgsN5g4uFDih9xYs&s=1W_xeZkwQeQkFKy6cr0hSeZk9KGNVPJA4GH-wrrpvGg&e=

If so this is a beta feature currently and you should raise any issues related to this in the EAC forum. It looks like they might have a bug.

I honestly believe there is nothing wrong with your code, but more with the ESRI code for _survey.py, which for some reason is trying to find a layer ending in “_fieldworker”, which is only generated when providing access to the data in web forms. This is all I can think about.

Let me know if you come out with any other ideas. Thanks a lot for your time. Javier

From: John notifications@github.com Sent: Thursday, April 11, 2019 5:07 PM To: nzjs/Automated-Survey123-Reports Automated-Survey123-Reports@noreply.github.com Cc: Vara, Javier jvara@tfs.tamu.edu; Mention mention@noreply.github.com Subject: Re: [nzjs/Automated-Survey123-Reports] Error with featureLayerUrl (#1)

Couple other things that I can maybe see an issue with:

The report_template variable is set to 1 in my example script. This is pointing to the second report template in the Survey123 Reports tab. Do you have two report templates or only one? If you only have one, this should be set to 0.

Is this your code in Survey123 API Access.py? survey.generate_report(template, querySurvey123) If so, I would try also adding utc_offset and report_title parameters as mentioned in the API docs.

I know they are optional but the remainder of my script depends on report_title existing to generate the reports and host them in the online space. https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.apps.survey123.html#arcgis.apps.survey123.Survey.generate_reporthttps://urldefense.proofpoint.com/v2/url?u=https-3A__esri.github.io_arcgis-2Dpython-2Dapi_apidoc_html_arcgis.apps.survey123.html-23arcgis.apps.survey123.Survey.generate-5Freport&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=elRSK8WZkJ3B4-PdcKAbKCalctHxbO31X_YOKK-Dm7k&s=kg2Vxfr_LMt3x6n8mlWGUCSE-70dkE3jtYtoVVtZIos&e=

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nzjs_Automated-2DSurvey123-2DReports_issues_1-23issuecomment-2D482341505&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=elRSK8WZkJ3B4-PdcKAbKCalctHxbO31X_YOKK-Dm7k&s=ZYGyTmHcosHcSCtstc_S_VSajqkbfcBSqk-UwOtjkck&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AvPfaDEI38MmGPVzNB8S57pitn-2DGze9qks5vf7HngaJpZM4cq1p7&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=elRSK8WZkJ3B4-PdcKAbKCalctHxbO31X_YOKK-Dm7k&s=k4grmUgoGqxP0c76XazwEx3YDmkx8gGFugg6Kj-Z464&e=.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/nzjs/Automated-Survey123-Reports/issues/1#issuecomment-482731446, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFEIX33phFtrO68-HIc6A-pjr2xY4w2Mks5vgPzYgaJpZM4cq1p7.

jvarasanz commented 5 years ago

Thanks John.

I always use connect, but didn't get fieldworker when I published, only stakeholder after I provided access to review the data. I may try to republish and see if that changes anything.

Thanks a lot. Javier

-------- Original message -------- From: John notifications@github.com Date: 4/12/19 16:58 (GMT-06:00) To: nzjs/Automated-Survey123-Reports Automated-Survey123-Reports@noreply.github.com Cc: "Vara, Javier" jvara@tfs.tamu.edu, Mention mention@noreply.github.com Subject: Re: [nzjs/Automated-Survey123-Reports] Error with featureLayerUrl (#1)

Thanks for your reply, that's really interesting.

Yes this is using the beta version of the API. I'll take a look at that when back in the office.

Another difference could be that my survey was created with the S123 Connect app rather than the web based editor? So my particular survey does have the _fieldworker and _stakeholder layers associated with it.

You could try publishing a new survey via the Connect app and try again. Interested to hear if that works.

Get Outlook for Androidhttps://aka.ms/ghei36


From: jvarasanz notifications@github.com Sent: Saturday, April 13, 2019 9:38:32 AM To: nzjs/Automated-Survey123-Reports Cc: John; Comment Subject: Re: [nzjs/Automated-Survey123-Reports] Error with featureLayerUrl (#1)

Good morning John.

Back with you. It’s been a loooooong day.

I only had one report template, so the report_template variable is set to 0. FYI, I had a print statement to confirm the report template and that is correct.

In regards to my code…. survey.generate_report(template, querySurvey123)… I am not setting any parameters for utc_offset and report_title. At this point I’m not using any more of your code, since I’m just checking if the report will generate first.

By the way, ESRI reply to a similar request with the following:

Are you using the Feature Report API as documented in Survey123 EAC site: https://earlyadopter.esri.com/project/article/item.html?cap=e69ef91f45744b98882c651f7b518eb7&arttypeid={5a8e51ed-4a87-43fe-a67d-2b7829af130f}&artid={0ECA95A6-000C-4C27-B062-8CC9DF44569E}https://urldefense.proofpoint.com/v2/url?u=https-3A__community.esri.com_external-2Dlink.jspa-3Furl-3Dhttps-253A-252F-252Fearlyadopter.esri.com-252Fproject-252Farticle-252Fitem.html-253Fcap-253De69ef91f45744b98882c651f7b518eb7-2526arttypeid-253D-257B5a8e51ed-2D4a87-2D43fe-2Da67d-2D2b7829af130f-257D-2526artid-253D-257B0ECA95A6-2D000C-2D4C27-2DB062-2D8CC9DF44569E-257D&d=DwMCaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=OX4BIqLK2INgmrO3qle5ANDH0pQYgsN5g4uFDih9xYs&s=1W_xeZkwQeQkFKy6cr0hSeZk9KGNVPJA4GH-wrrpvGg&e=

If so this is a beta feature currently and you should raise any issues related to this in the EAC forum. It looks like they might have a bug.

I honestly believe there is nothing wrong with your code, but more with the ESRI code for _survey.py, which for some reason is trying to find a layer ending in “_fieldworker”, which is only generated when providing access to the data in web forms. This is all I can think about.

Let me know if you come out with any other ideas. Thanks a lot for your time. Javier

From: John notifications@github.com Sent: Thursday, April 11, 2019 5:07 PM To: nzjs/Automated-Survey123-Reports Automated-Survey123-Reports@noreply.github.com Cc: Vara, Javier jvara@tfs.tamu.edu; Mention mention@noreply.github.com Subject: Re: [nzjs/Automated-Survey123-Reports] Error with featureLayerUrl (#1)

Couple other things that I can maybe see an issue with:

The report_template variable is set to 1 in my example script. This is pointing to the second report template in the Survey123 Reports tab. Do you have two report templates or only one? If you only have one, this should be set to 0.

Is this your code in Survey123 API Access.py? survey.generate_report(template, querySurvey123) If so, I would try also adding utc_offset and report_title parameters as mentioned in the API docs.

I know they are optional but the remainder of my script depends on report_title existing to generate the reports and host them in the online space. https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.apps.survey123.html#arcgis.apps.survey123.Survey.generate_reporthttps://urldefense.proofpoint.com/v2/url?u=https-3A__esri.github.io_arcgis-2Dpython-2Dapi_apidoc_html_arcgis.apps.survey123.html-23arcgis.apps.survey123.Survey.generate-5Freport&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=elRSK8WZkJ3B4-PdcKAbKCalctHxbO31X_YOKK-Dm7k&s=kg2Vxfr_LMt3x6n8mlWGUCSE-70dkE3jtYtoVVtZIos&e=

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nzjs_Automated-2DSurvey123-2DReports_issues_1-23issuecomment-2D482341505&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=elRSK8WZkJ3B4-PdcKAbKCalctHxbO31X_YOKK-Dm7k&s=ZYGyTmHcosHcSCtstc_S_VSajqkbfcBSqk-UwOtjkck&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AvPfaDEI38MmGPVzNB8S57pitn-2DGze9qks5vf7HngaJpZM4cq1p7&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=elRSK8WZkJ3B4-PdcKAbKCalctHxbO31X_YOKK-Dm7k&s=k4grmUgoGqxP0c76XazwEx3YDmkx8gGFugg6Kj-Z464&e=.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/nzjs/Automated-Survey123-Reports/issues/1#issuecomment-482731446, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFEIX33phFtrO68-HIc6A-pjr2xY4w2Mks5vgPzYgaJpZM4cq1p7.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nzjs_Automated-2DSurvey123-2DReports_issues_1-23issuecomment-2D482736164&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=Wj-NfqJIu4rkONM1H6Bblw8M3p9VNpAAqW_ibF695jw&s=naGaOVCFRqHa77YhaylRd9Rfx5D5_ie15KjwAJ5kl1o&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AvPfaHqTRBCaiYsXu962E-2DB7IhrGxX57ks5vgQGVgaJpZM4cq1p7&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=OW18nec5Z4WYnzYj8tkyMqdi4UWz1g1IfVdL0YFXdfQ&m=Wj-NfqJIu4rkONM1H6Bblw8M3p9VNpAAqW_ibF695jw&s=1Xh5wsHCZEpyuzlmqv0MNMR1YW_Xe07WQ4hHvwCNppM&e=.

nzjs commented 5 years ago

@jvarasanz Did you end up resolving this - can I close this issue?