using Meitner;
using Meitner.Models.Components;
var sdk = new MeitnerSDK(security: new Security() {
Option1 = new SecurityOption1() {
ClientCredentials = "<YOUR_API_KEY_HERE>",
ClientSecret = "<YOUR_API_KEY_HERE>",
},
});
SchoolCreate req = new SchoolCreate() {
External = new SchoolCreateExternal() {
SourceID = "12345678",
},
Title = "Meitner Grundskola",
UnitID = "123e4567-e89b-12d3-a456-426614174000",
UnitCode = "12345678",
CsnSchoolCode = "12345",
MunicipalityCode = "0184",
SchoolType = SchoolCreateSchoolType.Gr,
};
var res = await sdk.Schools.CreateAsync(req);
// handle responsefrom meitner import Meitner, models
import os
with Meitner(
security=models.Security(
option1=models.SecurityOption1(
client_credentials=os.getenv("MEITNER_CLIENT_CREDENTIALS", ""),
client_secret=os.getenv("MEITNER_CLIENT_SECRET", ""),
),
),
) as m_client:
res = m_client.schools.create(title="Meitner Grundskola", school_type="GR", external={
"source_id": "12345678",
}, unit_id="123e4567-e89b-12d3-a456-426614174000", unit_code="12345678", csn_school_code="12345", municipality_code="0184")
# Handle response
print(res)curl --request POST \
--url https://api.meitner.se/directory/v1/school \
--header 'Client-ID: <api-key>' \
--header 'Client-Secret: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"external": {
"sourceID": "12345678"
},
"title": "Meitner Grundskola",
"unitID": "123e4567-e89b-12d3-a456-426614174000",
"unitCode": "12345678",
"csnSchoolCode": "12345",
"municipalityCode": "0184",
"schoolType": "GR"
}
'const options = {
method: 'POST',
headers: {
'Client-ID': '<api-key>',
'Client-Secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
external: {sourceID: '12345678'},
title: 'Meitner Grundskola',
unitID: '123e4567-e89b-12d3-a456-426614174000',
unitCode: '12345678',
csnSchoolCode: '12345',
municipalityCode: '0184',
schoolType: 'GR'
})
};
fetch('https://api.meitner.se/directory/v1/school', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.meitner.se/directory/v1/school",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'external' => [
'sourceID' => '12345678'
],
'title' => 'Meitner Grundskola',
'unitID' => '123e4567-e89b-12d3-a456-426614174000',
'unitCode' => '12345678',
'csnSchoolCode' => '12345',
'municipalityCode' => '0184',
'schoolType' => 'GR'
]),
CURLOPT_HTTPHEADER => [
"Client-ID: <api-key>",
"Client-Secret: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.meitner.se/directory/v1/school"
payload := strings.NewReader("{\n \"external\": {\n \"sourceID\": \"12345678\"\n },\n \"title\": \"Meitner Grundskola\",\n \"unitID\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"unitCode\": \"12345678\",\n \"csnSchoolCode\": \"12345\",\n \"municipalityCode\": \"0184\",\n \"schoolType\": \"GR\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Client-ID", "<api-key>")
req.Header.Add("Client-Secret", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.meitner.se/directory/v1/school")
.header("Client-ID", "<api-key>")
.header("Client-Secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"external\": {\n \"sourceID\": \"12345678\"\n },\n \"title\": \"Meitner Grundskola\",\n \"unitID\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"unitCode\": \"12345678\",\n \"csnSchoolCode\": \"12345\",\n \"municipalityCode\": \"0184\",\n \"schoolType\": \"GR\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meitner.se/directory/v1/school")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Client-ID"] = '<api-key>'
request["Client-Secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"external\": {\n \"sourceID\": \"12345678\"\n },\n \"title\": \"Meitner Grundskola\",\n \"unitID\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"unitCode\": \"12345678\",\n \"csnSchoolCode\": \"12345\",\n \"municipalityCode\": \"0184\",\n \"schoolType\": \"GR\"\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000",
"meta": {
"createdAt": "2024-01-15T10:30:00Z",
"createdBy": "987fcdeb-51a2-43d1-b567-123456789abc",
"updatedAt": "2024-01-15T14:45:00Z",
"updatedBy": "987fcdeb-51a2-43d1-b567-123456789abc"
},
"external": {
"sourceID": "12345678",
"source": "ExternalIntegrationAPI"
},
"title": "Meitner Grundskola",
"unitID": "123e4567-e89b-12d3-a456-426614174000",
"unitCode": "12345678",
"csnSchoolCode": "12345",
"municipalityCode": "0184",
"schoolType": "GR"
}{
"error": {
"code": "BadRequest",
"message": "The request contains invalid parameters or malformed data",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "Unauthorized",
"message": "Authentication credentials are missing or invalid",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "Forbidden",
"message": "You do not have permission to perform this operation",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "NotFound",
"message": "The requested resource could not be found",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "Conflict",
"message": "The request conflicts with the current state of the resource",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "UnprocessableEntity",
"message": "Validation failed for School Create endpoint",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "RateLimited",
"message": "Too many requests - rate limit exceeded",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "Internal",
"message": "An unexpected server error occurred",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}Create a new School
Create a new School
using Meitner;
using Meitner.Models.Components;
var sdk = new MeitnerSDK(security: new Security() {
Option1 = new SecurityOption1() {
ClientCredentials = "<YOUR_API_KEY_HERE>",
ClientSecret = "<YOUR_API_KEY_HERE>",
},
});
SchoolCreate req = new SchoolCreate() {
External = new SchoolCreateExternal() {
SourceID = "12345678",
},
Title = "Meitner Grundskola",
UnitID = "123e4567-e89b-12d3-a456-426614174000",
UnitCode = "12345678",
CsnSchoolCode = "12345",
MunicipalityCode = "0184",
SchoolType = SchoolCreateSchoolType.Gr,
};
var res = await sdk.Schools.CreateAsync(req);
// handle responsefrom meitner import Meitner, models
import os
with Meitner(
security=models.Security(
option1=models.SecurityOption1(
client_credentials=os.getenv("MEITNER_CLIENT_CREDENTIALS", ""),
client_secret=os.getenv("MEITNER_CLIENT_SECRET", ""),
),
),
) as m_client:
res = m_client.schools.create(title="Meitner Grundskola", school_type="GR", external={
"source_id": "12345678",
}, unit_id="123e4567-e89b-12d3-a456-426614174000", unit_code="12345678", csn_school_code="12345", municipality_code="0184")
# Handle response
print(res)curl --request POST \
--url https://api.meitner.se/directory/v1/school \
--header 'Client-ID: <api-key>' \
--header 'Client-Secret: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"external": {
"sourceID": "12345678"
},
"title": "Meitner Grundskola",
"unitID": "123e4567-e89b-12d3-a456-426614174000",
"unitCode": "12345678",
"csnSchoolCode": "12345",
"municipalityCode": "0184",
"schoolType": "GR"
}
'const options = {
method: 'POST',
headers: {
'Client-ID': '<api-key>',
'Client-Secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
external: {sourceID: '12345678'},
title: 'Meitner Grundskola',
unitID: '123e4567-e89b-12d3-a456-426614174000',
unitCode: '12345678',
csnSchoolCode: '12345',
municipalityCode: '0184',
schoolType: 'GR'
})
};
fetch('https://api.meitner.se/directory/v1/school', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.meitner.se/directory/v1/school",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'external' => [
'sourceID' => '12345678'
],
'title' => 'Meitner Grundskola',
'unitID' => '123e4567-e89b-12d3-a456-426614174000',
'unitCode' => '12345678',
'csnSchoolCode' => '12345',
'municipalityCode' => '0184',
'schoolType' => 'GR'
]),
CURLOPT_HTTPHEADER => [
"Client-ID: <api-key>",
"Client-Secret: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.meitner.se/directory/v1/school"
payload := strings.NewReader("{\n \"external\": {\n \"sourceID\": \"12345678\"\n },\n \"title\": \"Meitner Grundskola\",\n \"unitID\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"unitCode\": \"12345678\",\n \"csnSchoolCode\": \"12345\",\n \"municipalityCode\": \"0184\",\n \"schoolType\": \"GR\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Client-ID", "<api-key>")
req.Header.Add("Client-Secret", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.meitner.se/directory/v1/school")
.header("Client-ID", "<api-key>")
.header("Client-Secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"external\": {\n \"sourceID\": \"12345678\"\n },\n \"title\": \"Meitner Grundskola\",\n \"unitID\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"unitCode\": \"12345678\",\n \"csnSchoolCode\": \"12345\",\n \"municipalityCode\": \"0184\",\n \"schoolType\": \"GR\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meitner.se/directory/v1/school")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Client-ID"] = '<api-key>'
request["Client-Secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"external\": {\n \"sourceID\": \"12345678\"\n },\n \"title\": \"Meitner Grundskola\",\n \"unitID\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"unitCode\": \"12345678\",\n \"csnSchoolCode\": \"12345\",\n \"municipalityCode\": \"0184\",\n \"schoolType\": \"GR\"\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000",
"meta": {
"createdAt": "2024-01-15T10:30:00Z",
"createdBy": "987fcdeb-51a2-43d1-b567-123456789abc",
"updatedAt": "2024-01-15T14:45:00Z",
"updatedBy": "987fcdeb-51a2-43d1-b567-123456789abc"
},
"external": {
"sourceID": "12345678",
"source": "ExternalIntegrationAPI"
},
"title": "Meitner Grundskola",
"unitID": "123e4567-e89b-12d3-a456-426614174000",
"unitCode": "12345678",
"csnSchoolCode": "12345",
"municipalityCode": "0184",
"schoolType": "GR"
}{
"error": {
"code": "BadRequest",
"message": "The request contains invalid parameters or malformed data",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "Unauthorized",
"message": "Authentication credentials are missing or invalid",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "Forbidden",
"message": "You do not have permission to perform this operation",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "NotFound",
"message": "The requested resource could not be found",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "Conflict",
"message": "The request conflicts with the current state of the resource",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "UnprocessableEntity",
"message": "Validation failed for School Create endpoint",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "RateLimited",
"message": "Too many requests - rate limit exceeded",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "Internal",
"message": "An unexpected server error occurred",
"requestID": "550e8400-e29b-41d4-a716-446655440000"
}
}Authorizations
Body
Request body
The title of the school
"Meitner Grundskola"
Type of schooling provided at the school
GR, GY, FS "GR"
External is the External-object used on Update and Create operations, since it should only be allowed to set SourceID for the school, the Source-field is not included.
Show child attributes
Show child attributes
{ "sourceID": "12345678" }
The ID of the Unit the school belongs to. Null if the school is not assigned to a Unit.
"123e4567-e89b-12d3-a456-426614174000"
null
The School Unit Code provided by SCB, is used in reports and printed on grade documents
"12345678"
null
The School Code provided by CSN, required for reports to CSN
"12345"
null
Municipality code of the school, is used in reports and printed on grade documents
"0184"
null
Response
Response for School Create operation - returns the created School
The School resource represents a school where daily operations occur. A school must exist before you can create StudentPlacements, EmployeePlacements, or Groups.
This resource can be created, updated, listed, retrieved, and searched using the standard resource structure.
Unique identifier for the School
"123e4567-e89b-12d3-a456-426614174000"
The title of the school
"Meitner Grundskola"
Type of schooling provided at the school
GR, GY, FS "GR"
Metadata information for the School
Show child attributes
Show child attributes
{
"createdAt": "2024-01-15T10:30:00Z",
"createdBy": "987fcdeb-51a2-43d1-b567-123456789abc",
"updatedAt": "2024-01-15T14:45:00Z",
"updatedBy": "987fcdeb-51a2-43d1-b567-123456789abc"
}
External is a reusable object that can be used to store external information about the school from another system, used for third-party integration tracking.
Show child attributes
Show child attributes
{
"sourceID": "12345678",
"source": "ExternalIntegrationAPI"
}
The ID of the Unit the school belongs to. Null if the school is not assigned to a Unit.
"123e4567-e89b-12d3-a456-426614174000"
null
The School Unit Code provided by SCB, is used in reports and printed on grade documents
"12345678"
null
The School Code provided by CSN, required for reports to CSN
"12345"
null
Municipality code of the school, is used in reports and printed on grade documents
"0184"
null