How to interpret data returned when making banner image API call?
Options

Gavin.McGruddy90
Posts: 4 🌱
in Development
Hi there, My team is currently creating a custom student dashboard widget for the main homepage. Pulling the various course information is working, but when trying to make the banner image call, we've hit a snag. This is the API call: GET /d2l/api/lp/(version)/courses/(orgUnitId)/image And although there isn't any network/server errors, this is the data returned: The documentation brings out that "a file stream containing the current course offering’s image" is returned, but my question is how can I interpret this into an HTML image tag to insert into the the rest of the HTML content we're coding? Thanks in advance! Gavin McGruddy
Tagged:
Answers
-
Hey Gavin,
If you're making the dashboard widget within Brightspace, you'll be able to put the route straight in your image tag like so:
<img src="http://(brightspaceUrl)/d2l/api/lp/(version)/courses/(orgUnitId)/image"></img>
Outside brightspace, you'll be able to build an authenticated route and use the same method.
If you really want to work with the byte array, you could also convert it to a base64 string, and set up your image tag like so:
<img src="data:image/png;base64,(Base64String)">
But I'd using the url method instead.
-
Hi Justin,
Yes I'm making the dashboard widget within Brightspace, and so that first option worked like a charm!
Thanks for your help!
Gavin
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