Hello, Running into some issues with updating a user's profile image through the POST /d2l/api...

*Update*
So far I have:
// from multer — upload.single(‘file)
const fileInfo = {
name: file.originalname,
contentType: file.mimetype,
buffer: file.buffer,
size: file.size,
};
const form = new FormData();
form.append('profileImage', fileInfo.buffer);
const config = {
method: 'post',
headers: {
...form.getHeaders(),
},
data: form,
};
await axios(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
I pulled this axios code from Postman. When this request is translated to HTTP, it is:
POST /api/lp/1.9/profile/myprofile/image?x_a={app_id}&x_b={user_id}&x_c={app_key}&x_d={user_key}&x_t={unix_timestamp_in_seconds}' HTTP/1.1
Host: some-edu.brightspace.com
Content-Length: 188
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="profileImage"; filename="profile.png"
Content-Type: image/png
(data)
----WebKitFormBoundary7MA4YWxkTrZu0gW
It looks like the example provided on the File uploads page for updating a profile image (https://docs.valence.desire2learn.com/basic/fileupload.html#simple-uploads), besides the boundary created by Postman. The axios response shows a redirect to /d2l/error/404/.
Not quite sure what to try next. Any help would be appreciated.
Thanks,
Dominic
Categories
- All Categories
- 6 Thought Leadership
- 7 Known and Fixed Issues
- 6 Product Roadmap
- 553 Archived
- 10 Accessibility
- 28 Community Corner
- 2 Welcome
- Updates
- Member Spotlights
- 4 Events
- 242 Development
- 746 Customer Enablement
- Evaluate - Assess Student Learning
- Get Comfortable with Brightspace
- Communicate - Engage with Your Students
- 1 Create - Set up your Brightspace course
- Action - Add or create student activities
- 26 Partners
- 8 Product News
- 2022
- 2022 Release Notes
- 2021 Release Notes
- 4 Training
- andycat