Can't access Stackscripts

Hello, I can't access the list of my stackscripts when utilizing the API/python. The only ones I can access are the public ones.

This is the code I've made, but I have no clue why I can't access them. My API KEY is correct, and it has full authorization when I check the "scope" section of it.

import requests
api_key = 'xxx'
main_url = 'https://api.linode.com/v4'
headers = {'Authorization': f'Bearer {api_key}'}
get_stacks = (main_url + '/linode/stackscripts')
r = requests.get(get_stacks,headers=headers)
print(f"Request URL: {r.request.url}")
print(f"Request Headers: {r.request.headers}")
print(f"Response Status Code: {r.status_code}")
print(f"Response Text: {r.text}")

1 Reply

To create an API call to list your StackScripts, you need to use the X-filter headers.

You'll see that is_public is listed as filterable and that the filter is boolean which here means that it can be set to either true or false. So, to list just private StackScripts, you'd want to use this in the heading along with the API Token:

 'X-Filter':'{"is_public": false}'

If you ever want to test a particular call, it might be helpful to try it in a simplified context to see if it works alone. For example, if you use the Linode CLI and run the command you're looking into with the --help flag, you would get this information:

linode-cli stackscripts list --help
linode-cli stackscripts list
StackScripts List
API Documentation: https://www.linode.com/docs/api/stackscripts/#stackscripts-list

You may filter results with:
  --label
  --description
  --deployments_total
  --is_public
  --rev_note
  --mine
Additionally, you may order results using --order-by and --order.

Based on that, running the following command with the CLI should return your Private StackScripts, which worked for me:

linode-cli stackscripts list --is_public false

If you get an error when doing that (and you're sure the CLI is properly configured and otherwise works), that would be a sign it's not an issue of syntax but rather could be an issue with the call itself.

I also wanted to note that sometimes you need to generate a new API token for this to work properly, especially if the key is old and was issued before a major API Update.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct