For å sende brev med vedlegg oppretter du en forsendelsesressurs på sørveren, men i tillegg til primary-document lister du også opp de dokumentene som er vedleggene i forsendelsen. Deretter bruker du lenkene med rel «https://api.digipost.no/relations/add_content» for å laste opp innholdet til alle dokumentene.
To send digital mail with attachments you must first create a message resource. In addition to specifying a primary-document you must also list the attachments you wish to send. Then you use the links with rel «https://api.digipost.no/relations/add_content» to add the actual content of the attachments to the established message resource.
Forsendelsen opprettes med følgende xml:
The message is created with the following xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>minMeldingsId ola.nordmann#1234 fa7d539f-59b4-4d25-874e-662320ff3152 Dokumentets emne 89499e46-43c7-4152-8714-e7aa6ce1392c Emne, vedlegg 1 94c02a60-619e-4339-a7e5-7a621174feec Emne, vedlegg 2
Responsen lister opp alle dokumenter i forsendelsen, og har status som indikerer at innhold må lastes opp.
The response includes all the documents that are included in the message. This status of the message (NOT_COMPLETE) indicates that the actual content of the documents must be added to the message.
201 Location: https://api.digipost.no/messages/1002 Content-Type: application/vnd.digipost-v5+xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?>minMeldingsId DIGIPOST NOT_COMPLETE fa7d539f-59b4-4d25-874e-662320ff3152 Dokumentets emne PASSWORD NORMAL false <link rel="https://api.digipost.no/relations/add_content" uri="http://localhost:8282/messages/1002/attachment/100200001/content" media-type="application/vnd.digipost-v5+xml"/>94c02a60-619e-4339-a7e5-7a621174feec Emne, vedlegg 2 PASSWORD NORMAL false <link rel="https://api.digipost.no/relations/add_content" uri="http://localhost:8282/messages/1002/attachment/100200002/content" media-type="application/vnd.digipost-v5+xml"/><link rel="https://api.digipost.no/relations/self" uri="https://api.digipost.no/messages/1002" media-type="application/vnd.digipost-v5+xml"/> <link rel="https://api.digipost.no/relations/send" uri="https://api.digipost.no/messages/1002/send" media-type="application/vnd.digipost-v5+xml"/> 89499e46-43c7-4152-8714-e7aa6ce1392c Emne, vedlegg 1 PASSWORD NORMAL false <link rel="https://api.digipost.no/relations/add_content" uri="https://api.digipost.no/messages/1002/attachment/100200003/content" media-type="application/vnd.digipost-v5+xml"/>
Tilsvarende som for forsendelsen med ett dokument, poster du nå hver av de 3 pdf-ene til de tre lenkene med rel «https://api.digipost.no/relations/add_content». For hvert kall får du tilbake tilsvarende respons hvor lenken du postet til har blitt erstattet med SHA256-sjekksummen til opplastet dokumentet. Legg spesielt merke til at rekkefølgen på vedlegg (attachment) er vilkårlig, og du må derfor bruke uuiden for hvert dokument for å gjenkjenne hvilken lenke som hører til hvert dokument.
Same as you would do when sending just one document, you now send three post requests for the three documents you wish to send. You use each of the three links with rel «https://api.digipost.no/relations/add_content» to do this. For each request you will reveive a response where the link you posted a request to has been replaced with the SHA256 checksum of the actual content of the document. Note that the order of the attachments in the XML is random, so make sure to use the uuid to relate the link to the actual document.
Når alle dokumentene er lastet opp får responsen status COMPLETE, og kan sendes med et POST-kall til lenken med rel «https://api.digipost.no/relations/send».
When the actual content of the three documents have been sent (one primary document and two attachments) the status of the message will change to COMPLETE. You can then send a post request to the link with rel «https://api.digipost.no/relations/send» to send the digital mail.
Responsen du får tilbake vil ha status DELIVERED.
The message in the response you then receive will have status DELIVERED.