iamntz
(Ionuț Staicu)
March 18, 2017, 6:19pm
1
Hey guys, I was wondering if there is a way of managing CSS/HTML customization via API. This means to fetch/update items here: admin/customize/css_html/
I’ve read this and didn’t had too much luck:
GET
ting this in POSTMAN {{base_url}}/admin/site_customizations/22?api_key={{api_key}}&api_username={{api_username}}
returns nothing;
GET
ting this in POSTMAN {{base_url}}/admin/site_customizations/
will return Oops! That page doesn’t exist or is private.
Thanks!
pfaffman
(Jay Pfaffman)
March 19, 2017, 2:46pm
2
Are you using the system api key?
iamntz
(Ionuț Staicu)
March 19, 2017, 2:54pm
3
Yeah, i did, but now i tried with an (admin) user API key and still not working.
1 Like
sam
(Sam Saffron)
March 20, 2017, 1:54pm
4
devtools says this is working:
curl 'https://meta.discourse.org/admin/site_customizations'
My guess is you have issues with your api keys or something.
1 Like
iamntz
(Ionuț Staicu)
March 20, 2017, 3:23pm
5
I feel dumb today Can you please give me a full curl sample?
My Postman cURL looks like this
curl -X GET
-H "Cache-Control: no-cache" -H "Postman-Token: xxx"
"https://my-site/admin/site_customizations/?api_key=my-api-taken-from-my-user-admin-page&api_username=my-username"
And the response looks like this:
(The username has administrator rights)
If i use postman to make a request that requires auth, it works:
{{base_url}}/admin/users/list/suspended.json?api_key={{api_key}}&api_username={{api_username}}
Works just fine.
sam
(Sam Saffron)
March 20, 2017, 4:29pm
6
My guess is that the controller is checking for XHR, maybe try adding:
x-requested-with:XMLHttpRequest
4 Likes
iamntz
(Ionuț Staicu)
March 20, 2017, 4:47pm
7
That was it! Thanks! (mark as solved? :D)
1 Like