Invalid value for reference field when importing from CSV

I have a CSV and here is the contents.

id,name,group
112 - Sao Paulo,112 - Sao Paulo,City

I have created a schema called location and its set up like so

{
  "id": "string",
  "data": {
    "id": {
      "iv": "string"
    },
    "name": {
      "en": "string"
    },
    "group": {
      "iv": [
        "string"
      ]
    }
  },
  "dataDraft": {
    "id": {
      "iv": "string"
    },
    "name": {
      "en": "string"
    },
    "group": {
      "iv": [
        "string"
      ]
    }
  },
  "version": 0,
  "created": "2019-10-01T14:03:51Z",
  "createdBy": "string",
  "lastModified": "2019-10-01T14:03:51Z",
  "lastModifiedBy": "string",
  "status": "string"
}

When using this command with the CLI

sq content import location result.csv --fields=id,name.en=name,group.iv=group --delimiter=,

I get the following error

Squidex Request failed: {"message":"Failed to create content.","details":["group: Not a valid value."],"statusCode":400}

However the format looks correct to me, could someone provide an example of referencing a referenceField when importing from CSV?

Thanks

For referernce I have also tried

sq content import location result.csv --fields=id,name.en=name,group=group --delimiter=,

and

sq content import location result.csv --fields=id,name.en=name,group.iv.0=group --delimiter=,

but i get the same error

Is the group a reference to another schema?

Correct that schema is structured like so

{
  "id": "string",
  "data": {
    "id": {
      "iv": "string"
    },
    "name": {
      "en": "string"
    }
  },
  "dataDraft": {
    "id": {
      "iv": "string"
    },
    "name": {
      "en": "string"
    }
  },
  "version": 0,
  "created": "2019-10-01T14:03:51Z",
  "createdBy": "string",
  "lastModified": "2019-10-01T14:03:51Z",
  "lastModifiedBy": "string",
  "status": "string"
}

and the City value has already been added to group schema

53

The CSV importer does not support references automatically. You need the ID of the referenced item to link your contents.

How should the importer know that you mean the name field of the group schema and what is the conflict strategy when there are 2 items with the same name?

ahhh ofcourse, got ya. I’ll give it a go using the Id.

Thank you

Works perfectly, thank you. Makes complete sense, not sure why i didnt think of it before. Thanks anyway

1 Like