CanonicalImportDataSpec content type

#1

The documentation says that the type of this field is ContentRef, which can be either json, csv or xml.
On the other hand, the content field of ContentRef is a string.
We are getting an invalid path value when trying to use stringified json instead of csv content, perhaps due to the @canonicalLegacy annotation in the canonical type.
Is it possible to import json content for such a canonical type?

0 Likes

How do it test on Jasmine in 7.8
#2

The trick is that contentType is a MIME one, not C3 one. So this works:

  var typeRef = DeepRef.make({
    typeName: ct
  }).toType()
  var csvText = decoder.decode(cv.content)
  var csvHead = typeRef.csvHeader().replace(/,/g, ';')
  return typeRef.importData({
    content: {
      contentType: 'text/csv',
      content: csvHead + '\n' + csvText
    }
  })

where ct is, for example, CanonicalMyType and cv is CSV ConentValue without header.
For JSON, one should put application/json instead of text/csv and JSON.stringifyed JSON array of objects as the inner content.

0 Likes