Ryan_NR
(Ryan)
September 30, 2019, 2:34pm
1
Hi folks - I’m an admin user of our Discourse instance - but I’m unable to query certain endpoints.
Sometimes I get this:
Other times I am prompted with You need to be logged in to do that
I have confirmed the API key I’m using is attached to my Admin user, and that the API_Username is my own username - do you have any advice on this?
My guess is the call is not sending the credentials correctly?
blake
(Blake Erickson)
October 1, 2019, 1:14pm
3
You could try passing the api credentials in the header of the request instead of the query params. There should be an example in the api documentation topic.
1 Like
Ryan_NR
(Ryan)
October 1, 2019, 1:14pm
4
Could be - I’m not sure - The set up I have is just the Postman collection downloaded from here:
Discourse API
Please view the Discourse API Documentation site for detailed info:
https://docs.discourse.org
Deprecation Warning!
On April 6th, 2020 we dropped support for all non-HTTP header based authentication (excluding some rss, mail-receiver, and ics routes). This means that API requests that have an api_key and api_username in the query params or in the HTTP body of the request will soon stop working. Please see the example cURL request below for how to update your API requ…
I just changed out the API Key, Username, and Base URL.
Is this collection no longer valid?
1 Like
Ryan_NR
(Ryan)
October 1, 2019, 1:15pm
5
Thanks @blake I’ll give it a try
blake
(Blake Erickson)
October 1, 2019, 1:17pm
6
Yea some of them are probably outdated.
1 Like
Ryan_NR
(Ryan)
October 1, 2019, 1:21pm
7
@blake - Passing creds as a request header is returning the same:
{
"errors": [
"You are not permitted to view the requested resource."
],
"error_type": "invalid_access"
}
blake
(Blake Erickson)
October 1, 2019, 1:52pm
8
I was able to get the group members api request to work on meta with this curl command:
curl -i -sS -X GET "https://meta.discourse.org/groups/my-private-group/members.json" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: key" \
-H "Api-Username: username"
Maybe you can use the copy as curl command in Postman and compare.
6 Likes
system
(system)
Closed
October 31, 2019, 1:55pm
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.