403 Forbidden error while doing GET request using python api

import requests
resp = requests.request("GET", "https://<my-instance>.octopus.app/api" ,
"headers" = {"Content-Type": "application/json",
"X-Octopus-ApiKey": "API-KEY"})

Response - 200

**but if i change my url to **
url = https://my-instance.octopus.app/api/licenses/licenses-current
and do
resp = requests.request(“GET”, url,
“headers” = {“Content-Type”: “application/json”,
“X-Octopus-ApiKey”: “API-KEY”})

I get an error like 403 Forbidden for URL. Please let me know what could be the issue as I’m new to octopus product.

Hi @amay.trivedi,

Thanks for getting in touch!

I’m not particularly familiar with python, so, can’t give you the exact fix for what you’re trying to do.
However, we have a repository of sample python scripts for interacting with our API available here: https://github.com/OctopusDeploy/OctopusDeploy-Api/tree/master/REST/python

These should help you get the basic structure needed for retrieving data from the API.

Regards,
Paul

Hi @paul.calvert,

Thanks for the quick response!!
Just want to know about licenses-current parameter. I’m getting it as “You do not have permission to perform this action. Please contact your Octopus administrator." Missing permission: AdministerSystem”. Should i follow any other steps. Please let me know

Hey @amay.trivedi,

That error code means the account that created the API Key doesn’t have that permission.

Would you be able to check the permissions of the account to see if it has that permission? If it doesn’t, could you talk to the admins to see if you can be allowed that permission?

Thanks,
Jeremy

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