Address results not checked for errors - page produces: Warning: Undefined array key "Collection"
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3529185. -->
Reported by: [joachim](https://www.drupal.org/user/107701)
Related to !7
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>I'm getting a lot of errors and no results for the page for a single address.</p>
<p>The errors start with:</p>
<pre>Warning: Undefined array key "Collection" in Drupal\localgov_waste_collection_whitespace_provider\Plugin\DataProvider\WhitespaceDataProvider->getCollections() (line 282 of /var/www/html/repos/localgov_waste_collection/modules/localgov_waste_collection_whitespace_provider/src/Plugin/DataProvider/WhitespaceDataProvider.php).</pre><p>The code in question is this:</p>
<pre> $json = json_encode($collectionsXml);<br> $monthCollections = json_decode($json, TRUE);<br><br> foreach ($monthCollections["Collection"] as $collection) {</pre><p>The problem is that the XML body being loaded up doesn't have any collections, but this error message instead:</p>
<pre> <s:Body><br> <GetCollectionByUprnAndDateResponse xmlns="http://webservices.whitespacews.com/"><br> <GetCollectionByUprnAndDateResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><br> <CodeDescription>No results returned</CodeDescription><br> <ErrorCode>6</ErrorCode><br> <ErrorDescription>No results returned</ErrorDescription><br> <SuccessFlag>false</SuccessFlag><br> <Collections i:nil="true"/><br> </GetCollectionByUprnAndDateResult><br> </GetCollectionByUprnAndDateResponse><br> </s:Body></pre><p>I *should* be getting results for the address I am using. </p>
<p>Could it be that my site's account with Whitespace is doing things differently?</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3 id="summary-ui-changes">User interface changes</h3>
<h3 id="summary-api-changes">API changes</h3>
<h3 id="summary-data-model-changes">Data model changes</h3>
> Related issue: [Issue #3529150](https://www.drupal.org/node/3529150)
issue