I would like to create page with API.No matter I put the css in inline or internal way, API fail to handle it.Are there any way that can apply CSS to API call? Thank you.
Hi @CartonKam,
I can probably at least point you in the right direction... You'll definitely need to use inline CSS, and there are only certain properties Canvas allows. I think you're running into an issue of escaping or encoding your html before passing it via the API. If you create a page in RCE and then get it with the API, you'll see:
"body": "<p style=\"color: red;\">A red paragraph</p>"
The slashes essentially escape the double quotes so there isn't confusion as to where the string begins or ends. I'd suggest trying that to see if posting that would work as you expect.
I've also moved this to the developers area where people who are more coding/api experts than me hang out, so someone else might chime in with even more useful info or exact advice.
Hope this helps a bit!
-Chris
@CartonKam @matthew_buckett Does this method allow you to circumvent uploading a CSS file to the Theme Editor if using in a single course?
@cgaudreau Nope, sorry. The same filtering is applied when using the API as when using the web UI so it will still remove style tags.
Ah...I had a feeling, but couldn't hurt to ask. Thanks for confirming @matthew_buckett.
Thanks for the detailed response! I guess the lesson is "stick with in-line styles" unless you like living on the edge with the sword of damocles hanging over your head. Given that the HTML is generated using python, I can write a quick filter that converts the class tags into style tags and not have to worry.
I looked through the LTI Variable Substitutions documentation and while there are variable substitutions available for Canvas.term.name and Canvas.term.id (which is the Canvas incremented ID like "104"), I was surprised to see there was no option for Canvas.term.sisSourceId I tried testing other possible variants that may…
Rendering bug here: Canvas - Instructure Community Seems to only appear in Edge; fine in Chrome and Firefox https://us.v-cdn.net/6038536/uploads/W3BKB9LY5FCV/recording-2026-04-08-144351.mp4
I have a developer key in our Test instance: How would I use this in a local program to make a REST API call? Looking at https://developerdocs.instructure.com/services/canvas/oauth2/file.developer_keys: Developer keys are OAuth2 client ID and secret pairs stored in Canvas that allow third-party applications to request…
I'm building a tool for my institution that imports grades from another LTI tool into Canvas so instructors can automate late assignment policies not otherwise supported by Canvas. I'm trying to use the LTIv1.3 ID which is readily available on the LTI-side as a link to the student record on Canvas, but I can't find the ID…
How can one track Canvas Media use without having the reports available from Canvas Studio? Checking API endpoints and the Data 2 schema, there do not seem to be dedicated Canvas Media endpoints. Am I missing some? A method I've considered is using the body field of the wiki_pages table, as this contains the html code of…