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

Dominic.DeSantis61
Posts: 4 🌱
in Development
*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', url: 'https://some-edu.brightspace.com/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}', 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.1Host: some-edu.brightspace.comContent-Length: 188Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ----WebKitFormBoundary7MA4YWxkTrZu0gWContent-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
Tagged:
Answers
-
Hi @Richard Martin ,
Thanks for looking into this. Seems like the the "/d2l" segment was lost somewhere while creating the authenticated URL. After adding it back I was able to successfully submit the request from Postman.
Thanks!
-
Hi @Dominic DeSantis ,
I think you are really close. At the beginning of your route, it is missing the `d2l ` segment. The full route should look like:
POST https://some-edu.brightspace.com/d2l/api/lp/1.30/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}'
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