Search code examples
javascriptckan

How to specify label and description fields in CKAN "datastore_create" API request


Im creating a datastore using CKAN API, but CKAN is ignoring the label and description properties:

const fields = [
  {
    id: "id_unique",
    type: "text",
    label: "label of id_unique", // CKAN ignoring this property
    description: "description of id_unique", // CKAN ignoring this property
  },
  {
    id: "latitude",
    type: "text",
    label: "label of latitude", // CKAN ignoring this property
    description: "description of latitude", // CKAN ignoring this property
  },
  {
    id: "longitude",
    type: "text",
    label: "label of longitude", // CKAN ignoring this property
    description: "description of longitude", // CKAN ignoring this property
  },
]

await clientAction('datastore_create', {
  package_id,
  resource_id,
  force,
  fields,
  records,
  primary_key,
})

Result:

enter image description here

How can I send the "label" and "description" properties?


Solution

  • Found out the solution. It's specified in a info field:

    const fields = [
      {
        id: "id_unique",
        type: "text",
        info: {
          notes: "description of id_unique",
          label: "label of id_unique",
        }
      },
      {
        id: "latitude",
        type: "text",
        info: {
          notes: "description of latitude",
          label: "label of latitude",
        }
      },
      {
        id: "longitude",
        type: "text",
        info: {
          notes: "description of longitude",
          label: "label of longitude",
        }
      },
    ]