Hey guys. I am currently using the API to get the device tags and device environment variables. I am using it in python the urls are:
https://api.resin.io/v4/device_tag?$filter=device/uuid eq ‘{}’
https://api.resin.io/v4/device_environment_variable?$filter=device eq {}
What I experience is that I often get rejected requests or I would rather say “invalid” ones. So basically, I will show you an example how I work with one of the links above.
get_all_environment_variables_device_url = 'https://api.resin.io/v4/device_environment_variable?$filter=device eq {}'
environment_variables = []
try:
response = requests.get(
get_all_environment_variables_device_url.format(device_id),
headers={"content-type":"application/json","Authorization":"Bearer {}".format(auth_token)}
)
if response.content == 'Unauthorized':
print('Invalid token provided. Unauthorized')
sys.exit(1)
environment_variables = json.loads(response.content)['d']
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S') + ' Type:{} Filename:{} Line:{} ERROR: {}'.format(exc_type, fname, exc_tb.tb_lineno,e))
So, basically, sometimes I get an error response from your side and it cannot load the environment variables. It’s happening exactly the same on the tags endpoint as well. Do you have any limits on the API and if you have how much are they? I am getting it quite often and it bothers me a bit. I can provide some additional info like status code and response content if you want.