Trying to use input variables to change our guest network's password and store code in github.
CAMPUS_GUEST_PSK = input("Please enter the new Campus-Guest password: ")
CAMPUS_GUEST_PSK_VARIABLE = 'CAMPUS_GUEST_PSK'
MERAKI_DASHBOARD_API_KEY = input("Please enter the Meraki API key: ")
API_KEY_ENVIRONMENT_VARIABLE = 'MERAKI_DASHBOARD_API_KEY'
import json
import requests
# Neqal-Wireless network
# Campus-Guest = SSID 1
payload = '''{
"psk": CAMPUS_GUEST_PSK
}'''
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"X-Cisco-Meraki-API-Key": MERAKI_DASHBOARD_API_KEY
}
response = requests.request('Put', url, headers=headers, data = payload)
print(response.text.encode('utf8'))
Getting the following when I run the python:
b'{"status":400,"error":"Bad request: There was a problem in the JSON you submitted"}'
if payload reads like the following:
payload = '''{
"psk": "CAMPUS_GUEST_PSK"
}'''
The password changes to CAMPUS_GUEST_PSK instead of what I inputted from the input prompts.
The API key is working fine and variable is working fine.