Discourse API - Unable to query certain endpoints

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?

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

Could be - I’m not sure - The set up I have is just the Postman collection downloaded from here:

I just changed out the API Key, Username, and Base URL.

Is this collection no longer valid?

1 Like

Thanks @blake I’ll give it a try

Yea some of them are probably outdated.

1 Like

@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"
}

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

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.