<?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 Is it possible to make a synchroniuos HTTP call from Synthetic monitor javascript execution step? in Synthetic Monitoring</title>
    <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/Is-it-possible-to-make-a-synchroniuos-HTTP-call-from-Synthetic/m-p/292414#M3310</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This is a follow-up to my earlier post:&lt;BR /&gt;&lt;A class="" href="https://community.dynatrace.com/t5/Synthetic-Monitoring/Synthetic-monitor-counting-api-fail-by-message-amp-custom-error/td-p/292309" target="_new" rel="noopener"&gt;https://community.dynatrace.com/t5/Synthetic-Monitoring/Synthetic-monitor-counting-api-fail-by-message-amp-custom-error/td-p/292309&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Could someone please confirm whether it is &lt;STRONG&gt;possible or not possible to make a synchronous HTTP call&lt;/STRONG&gt; from a &lt;STRONG&gt;Synthetic Monitor JavaScript execution step&lt;/STRONG&gt;?&lt;BR /&gt;If it &lt;EM&gt;is not possible&lt;/EM&gt;, could you please point me to the &lt;STRONG&gt;official documentation&lt;/STRONG&gt; where this behavior is described?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Regards, Deni&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 04 Jan 2026 19:30:49 GMT</pubDate>
    <dc:creator>deni</dc:creator>
    <dc:date>2026-01-04T19:30:49Z</dc:date>
    <item>
      <title>Is it possible to make a synchroniuos HTTP call from Synthetic monitor javascript execution step?</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/Is-it-possible-to-make-a-synchroniuos-HTTP-call-from-Synthetic/m-p/292414#M3310</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This is a follow-up to my earlier post:&lt;BR /&gt;&lt;A class="" href="https://community.dynatrace.com/t5/Synthetic-Monitoring/Synthetic-monitor-counting-api-fail-by-message-amp-custom-error/td-p/292309" target="_new" rel="noopener"&gt;https://community.dynatrace.com/t5/Synthetic-Monitoring/Synthetic-monitor-counting-api-fail-by-message-amp-custom-error/td-p/292309&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Could someone please confirm whether it is &lt;STRONG&gt;possible or not possible to make a synchronous HTTP call&lt;/STRONG&gt; from a &lt;STRONG&gt;Synthetic Monitor JavaScript execution step&lt;/STRONG&gt;?&lt;BR /&gt;If it &lt;EM&gt;is not possible&lt;/EM&gt;, could you please point me to the &lt;STRONG&gt;official documentation&lt;/STRONG&gt; where this behavior is described?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Regards, Deni&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jan 2026 19:30:49 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/Is-it-possible-to-make-a-synchroniuos-HTTP-call-from-Synthetic/m-p/292414#M3310</guid>
      <dc:creator>deni</dc:creator>
      <dc:date>2026-01-04T19:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a synchroniuos HTTP call from Synthetic monitor javascript execution step?</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/Is-it-possible-to-make-a-synchroniuos-HTTP-call-from-Synthetic/m-p/292415#M3311</link>
      <description>&lt;P&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/90225"&gt;@deni&lt;/a&gt;&amp;nbsp; , for HTTP synthetic tests, this is not possible, see this:&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/shortlink/http-monitor-pre-post-script#define-pre-and-post-execution-scripts" target="_blank" rel="noopener"&gt;https://docs.dynatrace.com/docs/shortlink/http-monitor-pre-post-script#define-pre-and-post-execution-scripts&lt;/A&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;SPAN&gt;Pre- and post-execution scripts have direct access only to the data retrieved as the result of the current request. In other words, the response details are available only within the same request’s post-execution script. To pass the information to a different request within the same monitor, use a&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/http-monitors-classic/pre-and-post-scripting-for-http-monitors-classic#variables" target="_blank" rel="noopener"&gt;variable&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;instead.&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;For Browser synthetic tests, this is certainly possible, for example, this one taken from the &lt;A href="https://docs.dynatrace.com/docs/shortlink/id-brower-clickpath-events#examples" target="_blank" rel="noopener"&gt;docs&lt;/A&gt;:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;api.startAsyncSyntheticEvent();
fetch('https://randomuser.me/api/').then((resp) =&amp;gt; resp.json()).then(function(data) {
    document.getElementById('firstName').value = data.results[0].name.first;
    document.getElementById('lastName').value = data.results[0].name.lastname;
    api.finish();
}).catch(function(error) {
    api.fail('Fetch request to randomuser.me failed');
});&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Here you need to call&amp;nbsp;api.startAsyncSyntheticEvent() so that the synthetic engine waits for api.fail() or api.finish() call. See &lt;A href="https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/browser-monitors/browser-clickpath-events#mark-events-as-failed-or-finished" target="_blank" rel="noopener"&gt;docs&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jan 2026 19:54:24 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/Is-it-possible-to-make-a-synchroniuos-HTTP-call-from-Synthetic/m-p/292415#M3311</guid>
      <dc:creator>Julius_Loman</dc:creator>
      <dc:date>2026-01-04T19:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a synchroniuos HTTP call from Synthetic monitor javascript execution step?</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/Is-it-possible-to-make-a-synchroniuos-HTTP-call-from-Synthetic/m-p/292422#M3312</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/3364"&gt;@Julius_Loman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question was related &lt;STRONG&gt;only to Browser Synthetic Monitors&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;The issue was caused by an incorrect placement of &lt;STRONG&gt;api.startAsyncSyntheticEvent()&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;In my original script, I had synchronous logic and an early return before calling &lt;STRONG&gt;api.startAsyncSyntheticEvent()&lt;/STRONG&gt;:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// Some synchronous code
var text = document.documentElement.innerText || '';
var someCheck = ...;

if (!someCheck) {
    return;
}

api.startAsyncSyntheticEvent(); // ❌ too late

fetch(...)
    .then(function(res) {
        if (!res.ok) {
            api.fail("FAIL_1");
            return;
        }
        api.fail("FAIL_2");
    })
    .catch(function(err) {
        api.fail("FAIL_3");
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;Because &lt;STRONG&gt;api.startAsyncSyntheticEvent()&lt;/STRONG&gt; was not called at the beginning of the JavaScript execution step, the Synthetic engine treated the step as synchronous and immediately moved on to the next step.&lt;BR /&gt;As a result, the &lt;STRONG&gt;asynchronous fetch() completed after the step had already finished&lt;/STRONG&gt;, and &lt;STRONG&gt;api.fail()&lt;/STRONG&gt; was &lt;STRONG&gt;ignored&lt;/STRONG&gt;, which made it look like synchronous execution was not supported.&lt;/P&gt;&lt;P&gt;Once I moved &lt;STRONG&gt;api.startAsyncSyntheticEvent()&lt;/STRONG&gt; to the very beginning of the JavaScript execution step and ensured that all execution paths end with either &lt;STRONG&gt;api.finish()&lt;/STRONG&gt; or&lt;STRONG&gt; api.fail()&lt;/STRONG&gt;, the monitor behaved as expected and failed on the JavaScript step with the correct failure message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;LI-CODE lang="markup"&gt;api.startAsyncSyntheticEvent();

// logic ...

fetch(...)
    .then(...)
    .catch(...);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So async HTTP calls are fully supported in Browser Synthetic Monitors, as long as &lt;STRONG&gt;api.startAsyncSyntheticEvent()&lt;/STRONG&gt; is invoked before any possible return path.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2026 08:32:16 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/Is-it-possible-to-make-a-synchroniuos-HTTP-call-from-Synthetic/m-p/292422#M3312</guid>
      <dc:creator>deni</dc:creator>
      <dc:date>2026-01-05T08:32:16Z</dc:date>
    </item>
  </channel>
</rss>

