iamntz
(Ionuț Staicu)
18 maart 2017 om 18:19
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)
19 maart 2017 om 14:46
2
Are you using the system api key?
iamntz
(Ionuț Staicu)
19 maart 2017 om 14:54
3
Yeah, i did, but now i tried with an (admin) user API key and still not working.
1 like
sam
(Sam Saffron)
20 maart 2017 om 13:54
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)
20 maart 2017 om 15:23
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)
20 maart 2017 om 16:29
6
My guess is that the controller is checking for XHR, maybe try adding:
x-requested-with:XMLHttpRequest
4 likes
iamntz
(Ionuț Staicu)
20 maart 2017 om 16:47
7
That was it! Thanks! (mark as solved? :D)
1 like