How to apply CSS with pages API ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023
08:24 PM
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.
Solved! Go to Solution.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023
12:28 AM
Creating a wiki page with inline CSS works for me, the difference i think is that I sent the parameters in the body of the request instead of as query parameters. Attached is a screenshot of a request:
This returned the following JSON from Canvas which appears to show the page correctly having CSS:
{
"title": "API Page-2",
"created_at": "2023-05-12T06:21:45Z",
"url": "api-page-2",
"editing_roles": "teachers",
"page_id": 383,
"last_edited_by": {
"id": 112,
"anonymous_id": "34",
"display_name": "Matthew Buckett",
"avatar_image_url": "https://secure.gravatar.com/avatar/0b238ed6001c42521b1ae20ea78e66ad?s=128&d=identicon",
"html_url": "https://oxeval.instructure.com/courses/164/users/112",
"pronouns": null
},
"published": false,
"hide_from_students": true,
"front_page": false,
"html_url": "https://oxeval.instructure.com/courses/164/pages/api-page-2",
"todo_date": null,
"publish_at": null,
"updated_at": "2023-05-12T06:21:45Z",
"locked_for_user": false,
"body": "<p style=\"color: red;\">A red paragraph</p>"
}
Postman should do the escaping for you when you send a request to Canvas, you only need to do escaping if you are sending the request body as JSON.