<?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 Ingest API using python script in Dynatrace API</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-API/Ingest-API-using-python-script/m-p/171567#M1391</link>
    <description>&lt;P&gt;Trying to get python requests to work with Metric Ingest.&amp;nbsp; Can use curl command line and it works .Using header with Content-Type text/plain as shown in documentation.&amp;nbsp; Data is as documented but python gives error .&amp;nbsp; &amp;nbsp;Here is curl part of script.&lt;/P&gt;
&lt;P&gt;datap = 'mymetric.connection,dt.entity.host:HOST-xxxxxxxxx,url=8999/connect 1'&lt;BR /&gt;header1 = '-H Authorization: Api-Token ' +mToken&lt;BR /&gt;header2 = '-H Content-Type: text/plain '&lt;BR /&gt;kcurl = 'curl -L -X POST '+apiurl+' '+header1+' '+header2+' --data '+datap&lt;/P&gt;
&lt;P&gt;Tried using the following for requests&amp;nbsp;&lt;/P&gt;
&lt;P&gt;headers = header1,header2&lt;/P&gt;
&lt;P data-unlink="true"&gt;response = requests.post('https://xxxxxxxxx.live.dynatrace.com/api/v2/metrics/ingest', headers=headers, data=datap)&lt;/P&gt;
&lt;P&gt;print(response)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;gives error&amp;nbsp; --&amp;gt;&amp;nbsp;AttributeError: 'tuple' object has no attribute 'items'&lt;/P&gt;</description>
    <pubDate>Mon, 29 May 2023 12:29:24 GMT</pubDate>
    <dc:creator>curtis_kellogg</dc:creator>
    <dc:date>2023-05-29T12:29:24Z</dc:date>
    <item>
      <title>Ingest API using python script</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Ingest-API-using-python-script/m-p/171567#M1391</link>
      <description>&lt;P&gt;Trying to get python requests to work with Metric Ingest.&amp;nbsp; Can use curl command line and it works .Using header with Content-Type text/plain as shown in documentation.&amp;nbsp; Data is as documented but python gives error .&amp;nbsp; &amp;nbsp;Here is curl part of script.&lt;/P&gt;
&lt;P&gt;datap = 'mymetric.connection,dt.entity.host:HOST-xxxxxxxxx,url=8999/connect 1'&lt;BR /&gt;header1 = '-H Authorization: Api-Token ' +mToken&lt;BR /&gt;header2 = '-H Content-Type: text/plain '&lt;BR /&gt;kcurl = 'curl -L -X POST '+apiurl+' '+header1+' '+header2+' --data '+datap&lt;/P&gt;
&lt;P&gt;Tried using the following for requests&amp;nbsp;&lt;/P&gt;
&lt;P&gt;headers = header1,header2&lt;/P&gt;
&lt;P data-unlink="true"&gt;response = requests.post('https://xxxxxxxxx.live.dynatrace.com/api/v2/metrics/ingest', headers=headers, data=datap)&lt;/P&gt;
&lt;P&gt;print(response)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;gives error&amp;nbsp; --&amp;gt;&amp;nbsp;AttributeError: 'tuple' object has no attribute 'items'&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 12:29:24 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Ingest-API-using-python-script/m-p/171567#M1391</guid>
      <dc:creator>curtis_kellogg</dc:creator>
      <dc:date>2023-05-29T12:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Ingest API using python script</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Ingest-API-using-python-script/m-p/171568#M1392</link>
      <description>&lt;P&gt;Your headers are incorrect. Go with:&lt;/P&gt;&lt;P data-unlink="true"&gt;headers = {"Authorization": "Api-Token " + token, "Content-Type": "text/plain"}&lt;BR /&gt;response = requests.post("https://xxxxxxxxx.live.dynatrace.com/api/v2/metrics/ingest", headers=headers, data="mymetric.connection,dt.entity.host:HOST-xxxxxxxxx,url=8999/connect 1")&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;Mike&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 13:41:29 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Ingest-API-using-python-script/m-p/171568#M1392</guid>
      <dc:creator>Mike_L</dc:creator>
      <dc:date>2021-09-01T13:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Ingest API using python script</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Ingest-API-using-python-script/m-p/171569#M1393</link>
      <description>&lt;P&gt;getting a different error now - i think it has something to do with the url=8999/connect part of the data - do I need to escape the / ?&lt;/P&gt;&lt;P&gt;&amp;lt;Response [400]&amp;gt;&lt;BR /&gt;{"linesOk":0,"linesInvalid":1,"error":{"code":400,"message":"1 invalid lines","invalidLines":[{"line":1,"error":"invalid dimension key in message 'mymetric.connection,dt.entity.host:HOST-CED4E27005B91CF6,url=899'; error at 'H' (index 35)"}]},"warnings":null}&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 13:57:17 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Ingest-API-using-python-script/m-p/171569#M1393</guid>
      <dc:creator>curtis_kellogg</dc:creator>
      <dc:date>2021-09-01T13:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Ingest API using python script</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Ingest-API-using-python-script/m-p/171570#M1394</link>
      <description>&lt;P&gt;the 400 was due to dt.entity.host:HOST-xxx&lt;/P&gt;&lt;P&gt;should have been&lt;/P&gt;&lt;P&gt;dt.entity.host=HOST-xxx.&amp;nbsp; It works now&lt;/P&gt;&lt;P&gt;got a 202 response&lt;/P&gt;&lt;P&gt;&amp;lt;Response [202]&amp;gt;&lt;BR /&gt;{"linesOk":1,"linesInvalid":0,"error":null,"warnings":null}&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 14:08:37 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Ingest-API-using-python-script/m-p/171570#M1394</guid>
      <dc:creator>curtis_kellogg</dc:creator>
      <dc:date>2021-09-01T14:08:37Z</dc:date>
    </item>
  </channel>
</rss>

