Mind the boundary
Your customer archives every posted sales invoice in an external document vault, and the vault's REST API accepts uploads only as multipart/form-data: one form field naming the archive category, plus the file itself. The last integration attempt sent the file as a plain text body, the vault answered 415 for a week, and nobody could say which CRLF was missing because nobody had ever written the framing down. This time the payload contract is written down — to the character — and the grader holds you to it.
Grading runs inside a container with no outbound network, so the request never travels over a real socket: sending goes through a tiny seam — an interface whose production implementation would wrap HttpClient.Send, and whose grading implementation is a mock vault the tests control. Everything up to that seam — the request, its headers, its body — is built exactly as if it were going to the real service.
Requirements
Create an interface named "Document Vault Transport" with exactly this declaration:
interface "Document Vault Transport"
{
procedure Send(Request: HttpRequestMessage; var StatusCode: Integer; var ResponseBody: Text)
}Send performs the one HTTP round trip: it transmits the request and hands back the response's status code and body text. You do not implement it — the grading mock does (and production code would, with HttpClient).
Then create a codeunit named "Multipart Upload Client" with exactly these two public procedures:
procedure BuildUploadRequest(Url: Text; Category: Text; FileName: Text; FileContent: InStream; var Request: HttpRequestMessage)
procedure UploadDocument(Url: Text; Category: Text; FileName: Text; FileContent: InStream; Transport: Interface "Document Vault Transport"): TextSolve it with Pro
You’re reading the opening of the statement. Pro unlocks the whole problem:
- The full statement
- Starter code in the browser editor
- 14 grading tests, run on Business Central 28.5
- 3 hints
- The reference solution
Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.
Already on Pro? Sign in