XML values and headers option in API

Hi,
Can you please tell me how to use the “XML values and headers” option in API(V2)?
I tried using “XML values and headers” in lang but didn’t work.

Hello @scary.scarecrow
According to my simple information, when API is used, it return only XML values and headers

1 Like

Hi @MohammedTaleb ,
Thanks. I’m not sure about that. Doesn’t it change based on lang parameter?
image

When downloading data from the site we can choose from list,
But when using an API, for example, fetching data in PowerBI, the data will be fetched as XML values and headers

1 Like

Thanks @MohammedTaleb
curl -X POST https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/exports/ allows following queries.

{
      "fields_from_all_versions": "true",
      "group_sep": "/",
      "hierarchy_in_labels": "true",
      "lang": "English (en)",
      "multiple_select": "both",
      "type": "geojson",
      "fields": ["field_1", "field_2"],
      "flatten": "true"
      "xls_types_as_text": "false",
      "include_media_url": "false",
      "submission_ids": [1, 2, 3, 4],
      "query": {
         "$and": [
             {"_submission_time": {"$gte": "2021-08-31"}},
             {"_submission_time": {"$lte": "2021-10-13"}}
         ]
       }
     }
   }

where:

  • “fields_from_all_versions” (required) is a boolean to specify whether fields from all form versions will be included in the export.
  • “group_sep” (required) is a value used to separate the names in a hierarchy of groups. Valid inputs include:
    • Non-empty value
  • “hierarchy_in_labels” (required) is a boolean to specify whether the group hierarchy will be displayed in labels
  • “multiple_select” (required) is a value to specify the display of multiple_select-type responses. Valid inputs include:
    • “both”,
    • “summary”, or
    • “details”
  • “type” (required) specifies the export format. Valid export formats include:
    • “csv”,
    • “geojson”,
    • “spss_labels”, or
    • “xls”
  • “fields” (optional) is an array of column names to be included in the export (including their group hierarchy). Valid inputs include:
    • An array containing any string value that matches the XML column name
    • An empty array which will result in all columns being included
    • If “fields” is not included in the “export_settings”, all columns will be included in the export
  • “flatten” (optional) is a boolean value and only relevant when exporting to “geojson” format.
  • “xls_types_as_text” (optional) is a boolean value that defaults to “false” and only affects “xls” export types.
  • “include_media_url” (optional) is a boolean value that defaults to “false” and only affects “xls” and “csv” export types. This will include an additional column for media-type questions (“question_name_URL”) with the URL link to the hosted file.
  • “submission_ids” (optional) is an array of submission ids that will filter exported submissions to only the specified array of ids. Valid inputs include:
    • An array containing integer values
    • An empty array (no filtering)
  • “query” (optional) is a JSON object containing a Mongo filter query for filtering exported submissions. Valid inputs include:
    • A JSON object containing a valid Mongo query
    • An empty JSON object (no filtering)

Among these options, I did not find any to define xml headers or values.

thanks @scary.scarecrow ,
I think the following link will help you:

1 Like

Thanks @MohammedTaleb ,
Unfortunately, it doesn’t have the answer I seek. Perhaps, @Josh can help?

Hi @MohammedTaleb, @scary.scarecrow it looks like we’ve missed the lang field in the documentation — thanks for spotting that! To answer your question, you can set lang to _xml for it to create an export using the same output as “XML values and headers” from the dropdown.

2 Likes

Thanks @Josh !

1 Like