extracting date from API

Solved
rsage_voda
Getting noticed

extracting date from API

I need to add an expiry date to self signed guest accounts on the Meraki cloud authentication portal. I am using the "PUT/networks/{networkId}/merakiAuthUsers/{merakiAuthUserId}"

This returns

"name": "Miles Meraki", "password": "secret", "emailPasswordToUser": false, "authorizations": [ { "ssidNumber": 1, "expiresAt": "never" I need to change this to a date and time 

"

The authorizations is a list but but it only appears to have 1 index 0

New Meraki Guest Users.jpg

I can find no way to extract the "expiresAt" dictionary value. My Tests in PyCharm

import datetime
import json
import itertools
from datetime import date
from datetime import datetime
from datetime import timedelta
MerakiUser = {
"name": "Russell Sage",
"password:": "Test123",
"emailPasswordToUser": False,
"authorizations" : [
{
"ssidNumber": 1,
"expiresAt": "never"
}
]
}
name = MerakiUser["name"]
print(name)
expiryDate = MerakiUser["authorizations"]
print(expiryDate)
print(type(expiryDate))
print(expiryDate.pop(1))

Traceback (most recent call last):
Dictionary.py", line 23, in <module>
print(expiryDate.pop(1))
IndexError: pop index out of range
Russell Sage
[{'ssidNumber': 1, 'expiresAt': 'never'}]
<class 'list'>

Process finished with exit code 1

 

Any assistance greatly received

1 Accepted Solution
alemabrahao
Kind of a big deal
Kind of a big deal

You can try this:

 

MerakiUser["authorizations"][0]["expiresAt"] = "2024-01-19T07:34:33Z" # replace with your desired expiry date

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

View solution in original post

2 Replies 2
alemabrahao
Kind of a big deal
Kind of a big deal

You can try this:

 

MerakiUser["authorizations"][0]["expiresAt"] = "2024-01-19T07:34:33Z" # replace with your desired expiry date

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

I have literally just worked that out for myself. I have spent hours on this. Grrrrr. Thank you for you confirmation

Get notified when there are additional replies to this discussion.