bc_upload_file
Uploads a local or base64 file into an open Business Central file-upload dialog to resume suspended AL upload code; invoke the page's upload action first and pass its page context ID.
Instructions
Upload a local file into a Business Central file-upload dialog, driving the page's AL Upload/UploadIntoStream code on the uploaded stream. This is a TWO-STEP flow: first invoke the page's upload action (bc_execute_action, e.g. "Import Layout" on Custom Report Layouts / page 9650) so BC opens the file-picker dialog (a FileUploadForm, returned in dialogsOpened), then call bc_upload_file with that page's pageContextId. The file is sent as a multipart POST to BC's DynamicFileUploadHandler over the same authenticated session, and the dialog is closed afterwards — exactly what the web client does — which resumes the suspended AL code on your bytes.
The upload targets the page's open FileUploadForm dialog automatically; optionally pass formId (the dialog formId from bc_execute_action's dialogsOpened) to target it explicitly. The call FAILS with a clear error instead of uploading when no FileUploadForm dialog is open — BC would otherwise silently discard the bytes (HTTP 200 with no effect), e.g. when the action failed and opened an error dialog instead, or when the invoked action is a declarative fileuploadaction (wire type fla, such as Extension Management's "Upload Extension..."), which uses a different protocol this tool does not serve.
Provide the file as either path (an absolute path to a local file) or base64 (inline content, with fileName).
The response reports the uploaded fileName, sizeBytes, the target formId, and any dialogsOpened the AL code raised in reaction to the file (e.g. a validation error for a bad file — respond to those with bc_respond_dialog, or re-read the page with bc_read_data to see the imported rows). This tool is for pushing a file TO BC; to retrieve files FROM BC (reports, "Open in Excel"), use bc_run_report / bc_execute_action, which return downloads[].
Example (local path): { "pageContextId": "session:page:9650:ab12", "path": "C:/tmp/layout.docx" } Example (base64): { "pageContextId": "session:page:9650:ab12", "base64": "UEsDBAo...", "fileName": "layout.docx" }
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"pageContextId": "<pageContextId>"
},
"name": "bc_upload_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Absolute path to a local file to upload. Provide exactly one of `path` or `base64`. | |
| base64 | No | Base64-encoded file content, as an alternative to `path`. Provide exactly one of `path` or `base64`. | |
| formId | No | Override the target dialog form id. By default the open FileUploadForm dialog on the page is used. Pass the form id from bc_execute_action's dialogsOpened to target a specific upload dialog; it must be a FileUploadForm. | |
| fileName | No | File name BC should see (e.g. "extension.app"). Required with `base64`; defaults to the basename of `path`. | |
| operationId | No | Optional idempotency key (e.g. a UUID you generate): a retry with the same key and arguments returns the stored result instead of re-running. See the server instructions. | |
| pageContextId | Yes | Page context ID of the host page whose upload action you just invoked (e.g. page 9650 after "Import Layout"). The open FileUploadForm dialog on that page is targeted automatically. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| formId | Yes | ||
| success | Yes | ||
| fileName | Yes | ||
| sizeBytes | Yes | ||
| replaySafe | Yes | ||
| dialogsOpened | Yes |