I have an usecase to download the records to excel. I am following the json-api spec and serializing all the records to json-api data. However I am experiencing serious performance issues since UI has to parse the json-api data for all the thousand’s of records and create the attachment (Excel/CSV).
I have another option of creating the attachment at server side and share the BASE 64 encoded bytes back to UI, which UI can easily transform to attachment.
Do we have any standards as per JSON API spec to follow for downloading the attachments. Please suggest
I don’t think needs to be modeled as an attachment, it’s just a different format. CSV instead of JSONAPI.
Whatever URL currently serves up the records in JSONAPI format could also send them in CSV format when the request has an Accept: text/csv header (as opposed to Accept: application/vnd.api+json).
Thanks for the response, but will that ensure we are not violating JSON API principles, since all our rest services are built following the json api specification.
JSONAPI is part of the wider family of open standards: http, json, mime, etc. I think using a separate mime type for CSV is a perfectly valid solution, not in conflict with JSONAPI at all.
By analogy: you usually wouldn’t use JSONAPI to serve images. You might use JSONAPI to get URLs that point at images, but then you’d use HTTP with an image-appropriate mime type to load the images. CSV can be handled the same way.