# API call runs fine in Dynatrace Harness, but not in Python - It's the &to and &from qualifiers

**URL:** <https://community.dynatrace.com/t/api-call-runs-fine-in-dynatrace-harness-but-not-in-python-its-the-to-and-from-qualifiers/42323>\
**Category:** Dynatrace API\
**Tags:** python, dynatrace-api\
**Created:** [October 26, 2023, 9:35pm UTC](https://community.dynatrace.com/t/api-call-runs-fine-in-dynatrace-harness-but-not-in-python-its-the-to-and-from-qualifiers/42323 "2023-10-26T21:35:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crabbylou](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@crabbylou](https://community.dynatrace.com/u/crabbylou)\
**Post date:** [October 26, 2023, 9:35pm UTC](https://community.dynatrace.com/t/api-call-runs-fine-in-dynatrace-harness-but-not-in-python-its-the-to-and-from-qualifiers/42323/1 "2023-10-26T21:35:10Z")

</div>

I execute these parameters in both the Dynatrace API harness and in Python.

metricSelector=builtin%3Akubernetes.container.restarts%3Afilter%28and%28or%28in%28%22dt.entity.cloud\_application\_namespace%22%2CentitySelector%28%22type%28cloud\_application\_namespace%29%2CentityName.equals%28~%22XXX-XXXXX-1~%22%29%22%29%29%29%2Cor%28in%28%22dt.entity.cloud\_application\_instance%22%2CentitySelector%28%22type%28cloud\_application\_instance%29%2CentityName.contains%28~%22FOO~%22%29%22%29%29%29%29%29%3Alimit%2820%29&from=2023-10-25T00%3A00%3A00.000%2B04%3A00&to=2023-10-25T00%3A01%3A00.000%2B04%3A00

**My issue is that it runs fine in the Dynatrace API harness, but NOT in Python, the &to and &from exclude all the data.**

I have constructed hundreds of queries, and this is just weird!!!  
Any advice would be appreciated.

Thanks,  
Lou

---

<div class="post-metadata">

**Author:** ![JamesKitson](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jameskitson/32/22460_2.png) [@JamesKitson](https://community.dynatrace.com/u/JamesKitson)\
**Post date:** [October 27, 2023, 2:21pm UTC](https://community.dynatrace.com/t/api-call-runs-fine-in-dynatrace-harness-but-not-in-python-its-the-to-and-from-qualifiers/42323/2 "2023-10-27T14:21:43Z")

</div>

I’m not familiar with Harness or any processing it may do on inputs.

You can try constructing it through the [API Explorer](https://docs.dynatrace.com/docs/shortlink/section-api#api-explorer) first and make sure the structure is right independent of Python or other tools. You may want to share your Python snippet as well.

Lastly, if you’re interested I recommend looking at our open-source [Python API client](https://github.com/dynatrace-oss/api-client-python) which includes methods for querying data from the metrics API so you just need to provide the inputs instead of creating the queries yourself.

---

<div class="post-metadata">

**Author:** ![crabbylou](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@crabbylou](https://community.dynatrace.com/u/crabbylou)\
**Post date:** [October 27, 2023, 6:05pm UTC](https://community.dynatrace.com/t/api-call-runs-fine-in-dynatrace-harness-but-not-in-python-its-the-to-and-from-qualifiers/42323/3 "2023-10-27T18:05:23Z")

</div>

I figured it out. It was a dumb programming error on my part. I was reading my date fields in Python as integers, and the lead zeroes on day, month, hour, minute and second were reading as integers and truncating lead zeroes.

Thanks! 🙂
