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 am calling the canvas API to get course Information. This is the endpoint that i am using /courses/{contextId}?include[]=account This is not returning the account.
Hi everyone, I am seeking some insight into how Canvas LMS handles HTTP errors and how they are reflected in the logs versus the user interface. We are currently observing the following behavior in our environment: Log-only errors: We are seeing 500 (Internal Server Error) and 503 (Service Unavailable) errors recorded in…
Hi everyone, If you write integrations against Canvas by Instructure at an institution — K-12, higher ed, corporate training, government, or anywhere in between — we'd love your feedback. We're running a short survey on the Canvas developer experience: APIs, data access, tooling, and documentation. Results will feed into…
I'm currently integrating an LTI tool and attempting to use the Activity.id.history https://canvas.instructure.com/doc/api/file.tools_variable_substitutions.html#activity-id-history variable, but I'm experiencing issues getting it to work properly. What I've Done: Added the Activity.id.history variable to my Developer…
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…