Import via JSON-API

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

SilverStripe v 4.4.2

I’ve been asked to provide a way of generating up-to-date data via a JSON-API call to a SilverStripe website.

The brief I have is:

  • the JSON file can be saved on the server and be served as a file instead of a direct API output, provided it is up-to-date (exported daily).
  • Information can be protected by HTTP basic authentication.
  • Example format:

{
“Timestamp”: “2020-09-29T16:04:02Z”, “TotalCount”: 1630,
“Results”: [

{ “id”: “1001”, “lastname”: “Muster”, “firstname”: “Peter”, “sex”: “m”, “nationalities”: [

{ “nationality”: “CH”, “nationality”: “DE”

} ],

“date_of_birth”: “1970-01-01”, “certification”: “Certified IFMGA Guide”, “certification_year”: “2000”,

page2image51406400|183.380000x0.600010

2

} ]

}

“further_qualification”: “Canyoning”, “address1”: “Teststrasse 4”, “address2”: “P.O. box”, “postal_code”: “8000”,

“city”: “Zürich”,
“country”: “Switzerland”,
“email”: “info@testmail.ch”,
“mobile”: “+41 79 123 45 67”,
“photo”: “https://servername/imagedir/1001”, “documents”: [

{
“diploma”: “https://servername/docdir/1001/diploma

}, {

“passport”: “https://servername/docdir/1001/passport” }

] },

{ “id”: “1002”, [etc.]

What is the best way of achieving this? Is there already a suitable module out there? Any advice/tips would be much appreciated!