<?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: HTTP Requests --&amp;gt; Script mode How can I add date variable in HTTP Get request in Synthetic Monitoring</title>
    <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/HTTP-Requests-gt-Script-mode-How-can-I-add-date-variable-in-HTTP/m-p/196706#M1534</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/55999"&gt;@vabg&lt;/a&gt; , good day.&lt;/P&gt;&lt;P&gt;To achieve this, you first need to set the variable in &lt;A href="https://www.dynatrace.com/support/help/how-to-use-dynatrace/synthetic-monitoring/http-monitors/pre-and-post-scripting-for-http-monitors#date-formatting" target="_self"&gt;pre-execution script&lt;/A&gt;, and then refer the variable in the URL, like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-10-18 at 09.11.28.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/8071i45CE104E3FD42835/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-10-18 at 09.11.28.png" alt="Screen Shot 2022-10-18 at 09.11.28.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;you can add any number of variables there to replace your requests params according.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, do confirm the proper date format syntax, and &lt;A href="https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html" target="_self"&gt;use this&lt;/A&gt; to get the right one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;based on the example you sent, your pre-execution script would be like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;api.setValue("dateToFormatCurrentDate", api.dateToFormat(api.date(), "yyyy-MM-dd'T'HH:mm:ss"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please try and let us know.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Oct 2022 12:18:22 GMT</pubDate>
    <dc:creator>dannemca</dc:creator>
    <dc:date>2022-10-18T12:18:22Z</dc:date>
    <item>
      <title>HTTP Requests --&gt; Script mode How can I add date variable in HTTP Get request</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/HTTP-Requests-gt-Script-mode-How-can-I-add-date-variable-in-HTTP/m-p/196695#M1533</link>
      <description>&lt;P&gt;I have this request and I want to use pick current date every time instead of hardcoding this value, I tried using&amp;nbsp;api.setValue("currentDate", api.dateToFormat(api.date(), "dd/MM/yy")); but its giving syntax error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know how can I achive this, basically in from and to in below URL I want it to pick current date everytime.&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"version": "1.0",&lt;BR /&gt;"requests": [&lt;BR /&gt;{&lt;BR /&gt;"description": "dev.testazure.test/test-service",&lt;BR /&gt;"url": "&lt;A href="https://dev.testazure.test/test-service/api/v1/eventhistory/notification?from=2022-09-12T04:35:51-0400&amp;amp;to=2022-09-12T05:35:51-0400" target="_blank"&gt;https://dev.testazure.test/test-service/api/v1/eventhistory/notification?from=2022-09-12T04:35:51-0400&amp;amp;to=2022-09-12T05:35:51-0400&lt;/A&gt;",&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"validation": {&lt;BR /&gt;"rules": [&lt;BR /&gt;{&lt;BR /&gt;"value": "&amp;gt;=400",&lt;BR /&gt;"passIfFound": false,&lt;BR /&gt;"type": "httpStatusesList"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;},&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 11:01:19 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/HTTP-Requests-gt-Script-mode-How-can-I-add-date-variable-in-HTTP/m-p/196695#M1533</guid>
      <dc:creator>vabg</dc:creator>
      <dc:date>2022-10-18T11:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Requests --&gt; Script mode How can I add date variable in HTTP Get request</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/HTTP-Requests-gt-Script-mode-How-can-I-add-date-variable-in-HTTP/m-p/196706#M1534</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/55999"&gt;@vabg&lt;/a&gt; , good day.&lt;/P&gt;&lt;P&gt;To achieve this, you first need to set the variable in &lt;A href="https://www.dynatrace.com/support/help/how-to-use-dynatrace/synthetic-monitoring/http-monitors/pre-and-post-scripting-for-http-monitors#date-formatting" target="_self"&gt;pre-execution script&lt;/A&gt;, and then refer the variable in the URL, like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-10-18 at 09.11.28.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/8071i45CE104E3FD42835/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-10-18 at 09.11.28.png" alt="Screen Shot 2022-10-18 at 09.11.28.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;you can add any number of variables there to replace your requests params according.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, do confirm the proper date format syntax, and &lt;A href="https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html" target="_self"&gt;use this&lt;/A&gt; to get the right one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;based on the example you sent, your pre-execution script would be like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;api.setValue("dateToFormatCurrentDate", api.dateToFormat(api.date(), "yyyy-MM-dd'T'HH:mm:ss"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please try and let us know.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 12:18:22 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/HTTP-Requests-gt-Script-mode-How-can-I-add-date-variable-in-HTTP/m-p/196706#M1534</guid>
      <dc:creator>dannemca</dc:creator>
      <dc:date>2022-10-18T12:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Requests --&gt; Script mode How can I add date variable in HTTP Get request</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/HTTP-Requests-gt-Script-mode-How-can-I-add-date-variable-in-HTTP/m-p/196731#M1535</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/18264"&gt;@dannemca&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help, its working fine.&lt;/P&gt;&lt;P&gt;Could you please also let me know if we have any method to return previous day date like api.date return present date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 14:43:39 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/HTTP-Requests-gt-Script-mode-How-can-I-add-date-variable-in-HTTP/m-p/196731#M1535</guid>
      <dc:creator>vabg</dc:creator>
      <dc:date>2022-10-18T14:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Requests --&gt; Script mode How can I add date variable in HTTP Get request</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/HTTP-Requests-gt-Script-mode-How-can-I-add-date-variable-in-HTTP/m-p/196738#M1536</link>
      <description>&lt;P&gt;You can "go crazy" using pre/post-execution script. You can do some math and calculate the previous date based on current date. It may requires some scripting skills, but doable.&lt;/P&gt;&lt;P&gt;Also, do check if the API you are calling does allow you to transform the date interval, like Dynatrace API does, example, "from=-24h to now", means all previous 24h.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 16:55:56 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/HTTP-Requests-gt-Script-mode-How-can-I-add-date-variable-in-HTTP/m-p/196738#M1536</guid>
      <dc:creator>dannemca</dc:creator>
      <dc:date>2022-10-18T16:55:56Z</dc:date>
    </item>
  </channel>
</rss>

