<?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 API Query parameter handling in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416614#M2891</link>
    <description>&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;I am attempting to write a script to pull events associated with non-meraki-vpns&lt;BR /&gt;&lt;BR /&gt;import requests&lt;BR /&gt;&lt;BR /&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;getNetworkAlerts&lt;/SPAN&gt;(headers, networkId, startDate, endDate):&lt;BR /&gt;    &lt;SPAN&gt;# Define the URL&lt;BR /&gt;&lt;/SPAN&gt;    url = (&lt;SPAN&gt;f"https://api.meraki.com/api/v1/networks/&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;networkId&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/events"&lt;/SPAN&gt;)&lt;BR /&gt;    params = {&lt;BR /&gt;        &lt;SPAN&gt;"productType"&lt;/SPAN&gt;: &lt;SPAN&gt;"appliance"&lt;/SPAN&gt;,&lt;BR /&gt;        &lt;SPAN&gt;"includedEventTypes[]"&lt;/SPAN&gt;: &lt;SPAN&gt;"non_meraki_vpn"&lt;/SPAN&gt;,&lt;BR /&gt;        &lt;SPAN&gt;"startingAfter"&lt;/SPAN&gt;:startDate,&lt;BR /&gt;        &lt;SPAN&gt;"endingBefore"&lt;/SPAN&gt;:endDate&lt;BR /&gt;    }&lt;BR /&gt;    &lt;SPAN&gt;# &lt;STRONG&gt;what is actually being sent to meraki dashboard&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;    req = requests.Request(&lt;SPAN&gt;'GET'&lt;/SPAN&gt;, url, &lt;SPAN&gt;headers&lt;/SPAN&gt;=headers, &lt;SPAN&gt;params&lt;/SPAN&gt;=params)&lt;BR /&gt;    prepared_request = req.prepare()&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;f'The full url to be sent is: &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;prepared_request.url&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;STRONG&gt;# Below in red is what requests builds.&lt;/STRONG&gt;&lt;BR /&gt;    &lt;FONT color="#FF0000"&gt;https://api.meraki.com/api/v1/networks/L_3895050727722058407/events?productType=appliance&amp;amp;includedEventTypes%5B%5D=non_meraki_vpn&amp;amp;startingAfter=2025-08-30+13%3A38%3A05.459567&amp;amp;endingBefore=2025-08-30+14%3A38%3A05.459567&lt;/FONT&gt;&lt;BR /&gt;    &lt;STRONG&gt;# Send the GET request&lt;/STRONG&gt;&lt;BR /&gt;    response = requests.get(url, &lt;SPAN&gt;headers&lt;/SPAN&gt;=headers, &lt;SPAN&gt;params&lt;/SPAN&gt;=params) status code 400&lt;BR /&gt;&lt;BR /&gt;However, if I build the url manually and don't use the keyword params&lt;BR /&gt;url = (&lt;SPAN&gt;f"https://api.meraki.com/api/v1/networks/&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;networkId&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/events?productType=appliacnce&amp;amp;includeEventTypes[]=non_meraki_vpn&amp;amp;startingAfter=2025-08-30 13:52:56.146621&amp;amp;endingBefore=2025-08-30 14:52:56.146621')&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;I don't get the error. But I can't encode varaiables directly into the url. Research suggests you do this by using the keyword params in the requests library&lt;BR /&gt;&lt;BR /&gt;Any more experienced coders out there got any advice please.&lt;/PRE&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sat, 30 Aug 2025 13:59:35 GMT</pubDate>
    <dc:creator>russell.sage</dc:creator>
    <dc:date>2025-08-30T13:59:35Z</dc:date>
    <item>
      <title>API Query parameter handling</title>
      <link>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416614#M2891</link>
      <description>&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;I am attempting to write a script to pull events associated with non-meraki-vpns&lt;BR /&gt;&lt;BR /&gt;import requests&lt;BR /&gt;&lt;BR /&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;getNetworkAlerts&lt;/SPAN&gt;(headers, networkId, startDate, endDate):&lt;BR /&gt;    &lt;SPAN&gt;# Define the URL&lt;BR /&gt;&lt;/SPAN&gt;    url = (&lt;SPAN&gt;f"https://api.meraki.com/api/v1/networks/&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;networkId&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/events"&lt;/SPAN&gt;)&lt;BR /&gt;    params = {&lt;BR /&gt;        &lt;SPAN&gt;"productType"&lt;/SPAN&gt;: &lt;SPAN&gt;"appliance"&lt;/SPAN&gt;,&lt;BR /&gt;        &lt;SPAN&gt;"includedEventTypes[]"&lt;/SPAN&gt;: &lt;SPAN&gt;"non_meraki_vpn"&lt;/SPAN&gt;,&lt;BR /&gt;        &lt;SPAN&gt;"startingAfter"&lt;/SPAN&gt;:startDate,&lt;BR /&gt;        &lt;SPAN&gt;"endingBefore"&lt;/SPAN&gt;:endDate&lt;BR /&gt;    }&lt;BR /&gt;    &lt;SPAN&gt;# &lt;STRONG&gt;what is actually being sent to meraki dashboard&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;    req = requests.Request(&lt;SPAN&gt;'GET'&lt;/SPAN&gt;, url, &lt;SPAN&gt;headers&lt;/SPAN&gt;=headers, &lt;SPAN&gt;params&lt;/SPAN&gt;=params)&lt;BR /&gt;    prepared_request = req.prepare()&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;f'The full url to be sent is: &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;prepared_request.url&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;STRONG&gt;# Below in red is what requests builds.&lt;/STRONG&gt;&lt;BR /&gt;    &lt;FONT color="#FF0000"&gt;https://api.meraki.com/api/v1/networks/L_3895050727722058407/events?productType=appliance&amp;amp;includedEventTypes%5B%5D=non_meraki_vpn&amp;amp;startingAfter=2025-08-30+13%3A38%3A05.459567&amp;amp;endingBefore=2025-08-30+14%3A38%3A05.459567&lt;/FONT&gt;&lt;BR /&gt;    &lt;STRONG&gt;# Send the GET request&lt;/STRONG&gt;&lt;BR /&gt;    response = requests.get(url, &lt;SPAN&gt;headers&lt;/SPAN&gt;=headers, &lt;SPAN&gt;params&lt;/SPAN&gt;=params) status code 400&lt;BR /&gt;&lt;BR /&gt;However, if I build the url manually and don't use the keyword params&lt;BR /&gt;url = (&lt;SPAN&gt;f"https://api.meraki.com/api/v1/networks/&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;networkId&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/events?productType=appliacnce&amp;amp;includeEventTypes[]=non_meraki_vpn&amp;amp;startingAfter=2025-08-30 13:52:56.146621&amp;amp;endingBefore=2025-08-30 14:52:56.146621')&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;I don't get the error. But I can't encode varaiables directly into the url. Research suggests you do this by using the keyword params in the requests library&lt;BR /&gt;&lt;BR /&gt;Any more experienced coders out there got any advice please.&lt;/PRE&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 30 Aug 2025 13:59:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416614#M2891</guid>
      <dc:creator>russell.sage</dc:creator>
      <dc:date>2025-08-30T13:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: API Query parameter handling</title>
      <link>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416615#M2892</link>
      <description>&lt;P&gt;You already posted a similar query &lt;A href="https://community.meraki.com/t5/Developers-APIs/GET-networks-networkId-events-productType-appliance-amp/m-p/281786#M12897" target="_blank"&gt;https://community.meraki.com/t5/Developers-APIs/GET-networks-networkId-events-productType-appliance-amp/m-p/281786#M12897&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you look at my reply, you'll see that your usage...&lt;/P&gt;&lt;PRE&gt;        &lt;SPAN&gt;"includedEventTypes[]"&lt;/SPAN&gt;: &lt;SPAN&gt;"non_meraki_vpn"&lt;/SPAN&gt;,&lt;/PRE&gt;&lt;P&gt;...is not correct.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Aug 2025 14:57:02 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416615#M2892</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2025-08-30T14:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: API Query parameter handling</title>
      <link>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416616#M2893</link>
      <description>&lt;P&gt;Also, this is not correct...&lt;/P&gt;&lt;PRE&gt;       &lt;SPAN&gt;"startingAfter"&lt;/SPAN&gt;:startDate,&lt;BR /&gt;        &lt;SPAN&gt;"endingBefore"&lt;/SPAN&gt;:endDate&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;These parameters are used by the pagination mechanism, you'll see that the documentation for the call says... "&lt;SPAN&gt;This parameter should not be defined by client applications."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developer.cisco.com/meraki/api-v1/get-network-events/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developer.cisco.com/meraki/api-v1/get-network-events/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I just grab the results and filter out the ones that are out of the desired date range.&lt;/P&gt;&lt;P&gt;The endpoint can be fiddly to use, for instance check for a non-Null 'Message' element  in the response, this may be used to signal that there are no matching events &lt;/P&gt;</description>
      <pubDate>Sat, 30 Aug 2025 15:08:34 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416616#M2893</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2025-08-30T15:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: API Query parameter handling</title>
      <link>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416617#M2894</link>
      <description>&lt;P&gt;Would you like to try the &lt;A href="https://developer.cisco.com/meraki/api-v1/python/#meraki-dashboard-api-python-library" target="_blank" rel="noopener nofollow noreferrer"&gt;Meraki Python SDK&lt;/A&gt;?&lt;/P&gt;&lt;P&gt;It will mask most of the lower level tweaks and help minimize mistakes. &lt;/P&gt;</description>
      <pubDate>Sat, 30 Aug 2025 15:14:57 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416617#M2894</guid>
      <dc:creator>obrigg</dc:creator>
      <dc:date>2025-08-30T15:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: API Query parameter handling</title>
      <link>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416618#M2895</link>
      <description>&lt;P&gt;I'm so used to people using the library that I didn't notice the OP was doing it the hard way.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Aug 2025 15:28:13 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/api-query-parameter-handling/m-p/5416618#M2895</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2025-08-30T15:28:13Z</dc:date>
    </item>
  </channel>
</rss>

