Post to the attachment child endpoint, not the page view URL: /rest/api/content/[page id]/child/attachment. Send it as multipart form data with the file field and the X-Atlassian-Token - nocheck header, authenticating with your normal API credentials. The common mistake is posting to the page URL you see in the browser, which is not a REST endpoint.

Context: Stack Overflow question (score 9, has accepted answer): Uploading an .xls file to a Confluence wiki page following the REST API docs keeps failing. The attempt posts multipart form data with the file and a comment to the page URL.