Error Encountered When Uploading File Using Moodle API Integration in NestJS

Re: Error Encountered When Uploading File Using Moodle API Integration in NestJS

by Bret Miller -
Number of replies: 0
Picture of Particularly helpful Moodlers
The file content is NOT passed as a parameter to the service. It's passed as a file form variable. The upload.php script uses $_FILES to retrieve the file content. Normally you replicate that by use a form field and get the value of it to add to the post formdata.

See https://moodledev.io/docs/4.4/apis/subsystems/external/files for more information. Note how curl is used with the -F parameter to attach a file object to the post data.

"filecontent" is not a valid parameter, hence the invalid parameter exception.