<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: JSON Response - limit search top 20lines only- HTTP Monitor script in Synthetic Monitoring</title>
    <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/JSON-Response-limit-search-top-20lines-only-HTTP-Monitor-script/m-p/185415#M1289</link>
    <description>&lt;P&gt;You can parse the response body as json. I guess you'd want something like:&lt;/P&gt;
&lt;P&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;var responseBody = response.getResponseBody();&lt;/I&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;var&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN class="c-mrkdwn__highlight"&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;json&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;Data =&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN class="c-mrkdwn__highlight"&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;JSON&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;.&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN class="c-mrkdwn__highlight"&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;parse&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;(responseBody);&lt;/I&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;var ps=&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN class="c-mrkdwn__highlight"&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;json&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;Data.runs[0].success;&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Apr 2022 12:54:39 GMT</pubDate>
    <dc:creator>HannahM</dc:creator>
    <dc:date>2022-04-25T12:54:39Z</dc:date>
    <item>
      <title>JSON Response - limit search top 20lines only- HTTP Monitor script</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/JSON-Response-limit-search-top-20lines-only-HTTP-Monitor-script/m-p/163620#M805</link>
      <description>&lt;P&gt;We have a swagger API which outputs a JSON response that has status detail about the execution of our batchjob.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my post execution script of HTTPMonitor of Dynatrace synthetics, I have this logic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;responseObject = JSON.parse(response.getResponseBody());&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;responseObject.runs.forEach(x =&amp;gt; {&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (x.success != true) {&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; api.fail(x.id + " failed");&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;});&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Batch jobs runs once a day. Our swagger JSON response has status details of last 50executions in the JSON body. I'm only interested in the 0 response - which has the status info of basically today's execution &amp;amp; ignore all the rest.&amp;nbsp; The above logic works when last 50th execution has no "success&amp;nbsp;:fail" in them&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone knows how to limit the search in post execution script of an HTTP Monitor to only look for 0 iteration,&amp;nbsp; or ,&amp;nbsp; search first 20lines only &amp;amp; ignore rest of the JSON payload, and if you find "success&amp;nbsp;:true" that means batch job ran successfully. Because&amp;nbsp;first 20 lines has the last execution detail in&lt;STRONG&gt; it..&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 14:00:49 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/JSON-Response-limit-search-top-20lines-only-HTTP-Monitor-script/m-p/163620#M805</guid>
      <dc:creator>shahrukh_niazi</dc:creator>
      <dc:date>2021-05-27T14:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Response - limit search top 20lines only- HTTP Monitor script</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/JSON-Response-limit-search-top-20lines-only-HTTP-Monitor-script/m-p/163623#M806</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shahrukh_niazi_0-1617143137089.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/461iC1B677D35C81D3FF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shahrukh_niazi_0-1617143137089.png" alt="shahrukh_niazi_0-1617143137089.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shahrukh_niazi_1-1617143247394.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/462i4745F31F2D0027B5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shahrukh_niazi_1-1617143247394.png" alt="shahrukh_niazi_1-1617143247394.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 22:27:34 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/JSON-Response-limit-search-top-20lines-only-HTTP-Monitor-script/m-p/163623#M806</guid>
      <dc:creator>shahrukh_niazi</dc:creator>
      <dc:date>2021-03-30T22:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Response - limit search top 20lines only- HTTP Monitor script</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/JSON-Response-limit-search-top-20lines-only-HTTP-Monitor-script/m-p/185313#M1276</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This thread is left unanswered so far, but maybe somebody would find anything that would help anyone who faces similar issue like mentioned above now or in future?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you in advance for any feedback!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 09:14:50 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/JSON-Response-limit-search-top-20lines-only-HTTP-Monitor-script/m-p/185313#M1276</guid>
      <dc:creator>Michal_Gebacki</dc:creator>
      <dc:date>2022-04-22T09:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Response - limit search top 20lines only- HTTP Monitor script</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/JSON-Response-limit-search-top-20lines-only-HTTP-Monitor-script/m-p/185415#M1289</link>
      <description>&lt;P&gt;You can parse the response body as json. I guess you'd want something like:&lt;/P&gt;
&lt;P&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;var responseBody = response.getResponseBody();&lt;/I&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;var&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN class="c-mrkdwn__highlight"&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;json&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;Data =&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN class="c-mrkdwn__highlight"&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;JSON&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;.&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN class="c-mrkdwn__highlight"&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;parse&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;(responseBody);&lt;/I&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;var ps=&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN class="c-mrkdwn__highlight"&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;json&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG data-stringify-type="bold"&gt;&lt;I data-stringify-type="italic"&gt;Data.runs[0].success;&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 12:54:39 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/JSON-Response-limit-search-top-20lines-only-HTTP-Monitor-script/m-p/185415#M1289</guid>
      <dc:creator>HannahM</dc:creator>
      <dc:date>2022-04-25T12:54:39Z</dc:date>
    </item>
  </channel>
</rss>

