How to request a JSON response from C3.ai COVID-19 API's?

I am querying C3.ai API’s for analyzing unified COVID-19 data. I see that all the API’s return an xml formatted string, by default. Currently, I am converting the format to json using the python library, xmltodict . Is there a way I can directly request a JSON response?

Here’s the code I am running:

import json, requests, xmltodict
url = "https://api.c3.ai/covid/api/1/outbreaklocation/fetch/"
request_data = {
    "spec": {
        "include": "id",
        "limit": 1
    }
}
response = requests.post(url=url, json=request_data)
print(response.text)

And the corresponding response I get is as follows:

<fetchResponse version="2.0">
  <type>
    <module>metadata</module>
    <name>FetchResult</name>
    <bindings>
      <k>T</k>
      <v>
        <type>
          <module>typesys</module>
          <name>ReferenceType</name>
        </type>
        <name>OutbreakLocation</name>
        <mixing>true</mixing>
      </v>
    </bindings>
  </type>
  <objs>
    <k>0</k>
    <v>
      <id>AaenHunze_Drenthe_Netherlands</id>
      <meta>
        <fetchInclude>[id,version,typeIdent]</fetchInclude>
        <fetchType>OutbreakLocation</fetchType>
      </meta>
      <version>262145</version>
      <typeIdent>EP_LOC</typeIdent>
    </v>
  </objs>
  <count>1</count>
  <hasMore>true</hasMore>
</fetchResponse>

And I am using the following piece of code to convert the xml to json:

fetch_object = xmltodict.parse(response.text)

one thing you could try would be to specify a Content Type header with your request.

import json, requests, xmltodict
url = "https://api.c3.ai/covid/api/1/outbreaklocation/fetch/"
headers={'content-type': 'application/json'}
request_data = {
    "spec": {
        "include": "id",
        "limit": 1
    }
}
response = requests.post(url=url, json=request_data, headers=headers)
print(response.text)