Hi, I'm attempting to use the arcgis Python API to create a GP service to generate S123 feature reports, and simply return an array of item ids. The code below runs, but it does not appear to be generating a new report. The only two items in the survey.reports array are the template (not sure why it'd even show up), and a report previously generated directly from the S123 website.
I'm also not seeing any new items under My Content in AGOL.
Any tips?
Thanks!
Brad
survey <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameter<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># '0d87ba0b72cf4c32b35c1db4d58c370d'</SPAN>
username <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameter<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># '<un>'</SPAN>
password <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameter<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># '<pwd>'</SPAN>
template <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameter<SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># 3</SPAN>
where <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameter<SPAN class="punctuation token">(</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># '"objectIds":"3,4"'</SPAN>
utc_offset <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameter<SPAN class="punctuation token">(</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># '-07:00'</SPAN>
title <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameter<SPAN class="punctuation token">(</SPAN><SPAN class="number token">6</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># 'My_Report'</SPAN>
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN>None<SPAN class="punctuation token">,</SPAN> username<SPAN class="punctuation token">,</SPAN> password<SPAN class="punctuation token">)</SPAN>
sm <SPAN class="operator token">=</SPAN> SurveyManager<SPAN class="punctuation token">(</SPAN>gis<SPAN class="punctuation token">)</SPAN>
survey <SPAN class="operator token">=</SPAN> sm<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>survey<SPAN class="punctuation token">)</SPAN>
template_id <SPAN class="operator token">=</SPAN> survey<SPAN class="punctuation token">.</SPAN>report_templates<SPAN class="punctuation token">[</SPAN>template<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>id
survey<SPAN class="punctuation token">.</SPAN>generate_report<SPAN class="punctuation token">(</SPAN>survey<SPAN class="punctuation token">.</SPAN>report_templates<SPAN class="punctuation token">[</SPAN>template<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> where<SPAN class="punctuation token">,</SPAN> utc_offset<SPAN class="punctuation token">,</SPAN> title<SPAN class="punctuation token">)</SPAN>
report_id_arr <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> report <SPAN class="keyword token">in</SPAN> survey<SPAN class="punctuation token">.</SPAN>reports<SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'doc id: '</SPAN> <SPAN class="operator token">+</SPAN> report<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> report<SPAN class="punctuation token">.</SPAN>id <SPAN class="operator token">!=</SPAN> template_id<SPAN class="punctuation token">:</SPAN>
report_id_arr<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>report<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">)</SPAN>
report_ids <SPAN class="operator token">=</SPAN> <SPAN class="string token">'["'</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">'", "'</SPAN><SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>report_id_arr<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">'"]'</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'doc ids: '</SPAN> <SPAN class="operator token">+</SPAN> report_ids<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">7</SPAN><SPAN class="punctuation token">,</SPAN> report_ids<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>