Last modified: May 28, 2024

API test org

When running the applications locally along with the local test platform one can test the APIs the application exposes.

Appen har en rekke API som kan benyttes av applikasjonseier/tjenesteeier. Beskrivelsen du finner her er laget for Postman hvor det er benyttet testapplikasjonen MVA testapp.

Postman-prosjektet kan lastes ned fra her (høyreklikk og velg “save as”).

Autentisering av tjenesteier org

I testmiljø og produksjon brukes maskinporten for å autentisere organisasjoner som eier apper.

Testplattformen for lokal testing tilbyr et enkelt api for å autentisere organisjonen som er ansvarlig.

Man trenger bare å oppgi tjenesteeier kode (som f.eks brg, skd osv)

Url: http://local.altinn.cloud/Home/GetTestOrgToken/ttd (ttd needs to be replaced with the org you want to authenticate)

The response is a JWT token that should be uses as a Authorization header.

Login
Login request

Multipart instansiering

Applikasjonene støtter at man instansierer instanser til aktører. Personer eller organsiasjoner.

Url: http://local.altinn.cloud/ttd/mva/instances

Metode: POST

Headers:

  • Authorization: Bearer + jwttoken
  • Content-Type: multipart/form-data; boundary=“abcdefg”

headers
Headers for multipart instansiering

Eksempel Body:

--abcdefg
Content-Type: application/json; charset=utf-8
Content-Disposition: form-data; name="instance"

{
    "instanceOwner": {
    	"organisationNumber" : "897069650"
    }
}

--abcdefg
Content-Type: application/xml
Content-Disposition: form-data; name="RF0002"

<?xml version="1.0"?>
<Skjema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" skjemanummer="212" spesifikasjonsnummer="10420" blankettnummer="RF-0002" tittel="Alminnelig omsetningsoppgave" gruppeid="20">
	<GenerellInformasjon-grp-2581 gruppeid="2581">
		<Avgiftspliktig-grp-50 gruppeid="50">
			<RapporteringsenhetNavn-datadef-21771 orid="21771">DDG Fitness</RapporteringsenhetNavn-datadef-21771>
			<RapporteringsenhetAdresse-datadef-21773 orid="21773">Sofies Gate 1</RapporteringsenhetAdresse-datadef-21773>
			<RapporteringsenhetPostnummer-datadef-21774 orid="21774">0170</RapporteringsenhetPostnummer-datadef-21774>
            <RapporteringsenhetPoststed-datadef-21775 orid="21775">By</RapporteringsenhetPoststed-datadef-21775>
            <RapporteringsenhetOrganisasjonsnummer-datadef-21772 orid="21772">897069650</RapporteringsenhetOrganisasjonsnummer-datadef-21772>
        </Avgiftspliktig-grp-50>
    </GenerellInformasjon-grp-2581>
</Skjema>

--abcdefg--

Example Response

The below response show how an instance was created for a given organization.

 1{
 2    "id": "500000/b4a42747-882f-47fa-bcd3-94029fdbc918",
 3    "instanceOwner": {
 4        "partyId": "500000",
 5        "personNumber": null,
 6        "organisationNumber": "897069650"
 7    },
 8    "appId": "ttd/mva",
 9    "org": "ttd",
10    "selfLinks": {
11        "apps": "https://local.altinn.cloud/ttd/mva/instances/500000/b4a42747-882f-47fa-bcd3-94029fdbc918",
12        "platform": "https://localhost:5101/storage/api/v1/instances/500000/b4a42747-882f-47fa-bcd3-94029fdbc918"
13    },
14    "dueBefore": null,
15    "visibleAfter": null,
16    "title": {
17        "nb": "RF-0002"
18    },
19    "process": {
20        "started": "2020-01-24T06:37:48.6026647Z",
21        "startEvent": "StartEvent_1",
22        "currentTask": {
23            "flow": 2,
24            "started": "2020-01-24T06:37:48.6027116Z",
25            "elementId": "Task_1",
26            "name": "Utfylling",
27            "altinnTaskType": "data",
28            "ended": null,
29            "validated": null
30        },
31        "ended": null,
32        "endEvent": null
33    },
34    "status": null,
35    "appOwner": {
36        "labels": null,
37        "messages": null,
38        "canBeDeletedAfter": null
39    },
40    "data": [
41        {
42            "id": "54d868aa-5bc9-47fb-9525-67ba4c2e595c",
43            "instanceGuid": "b4a42747-882f-47fa-bcd3-94029fdbc918",
44            "dataType": "RF0002",
45            "filename": null,
46            "contentType": "application/xml",
47            "blobStoragePath": "ttd/mva/b4a42747-882f-47fa-bcd3-94029fdbc918/data/54d868aa-5bc9-47fb-9525-67ba4c2e595c",
48            "selfLinks": {
49                "apps": "https://local.altinn.cloud/ttd/mva/instances/500000/b4a42747-882f-47fa-bcd3-94029fdbc918/data/54d868aa-5bc9-47fb-9525-67ba4c2e595c",
50                "platform": "https://localhost:5101/storage/api/v1/instances/500000/b4a42747-882f-47fa-bcd3-94029fdbc918/data/54d868aa-5bc9-47fb-9525-67ba4c2e595c"
51            },
52            "size": 1009,
53            "locked": false,
54            "refs": [],
55            "created": "2020-01-24T06:37:48.641997Z",
56            "createdBy": null,
57            "lastChanged": "2020-01-24T06:37:48.641997Z",
58            "lastChangedBy": null
59        }
60    ],
61    "created": "2020-01-24T06:37:48.6068671Z",
62    "createdBy": null,
63    "lastChanged": "2020-01-24T06:37:48.6068671Z",
64    "lastChangedBy": null
65}