exiva/Vizio_SmartCast_API

Invalid Parameter when trying to send a remote control button press command

Closed this issue · 2 comments

Code:

import requests
import json

from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

AUTH = '3vbegngm6c'

headers = {'Content-Type':'application/json', 'AUTH': AUTH}

url = 'https://192.168.0.6:9000/key_command'

def make_request(codeset, code):
    data = {"KEYLIST": [{"CODESET": codeset,"CODE": code,"ACTION":"KEYPRESS"}]}

    r = requests.put(
        url,
        data = json.dumps(data),
        headers = headers,
        verify=False
    )
    return r

r = make_request(5,0)
print r.json()

Logs:
{u'STATUS': {u'RESULT': u'INVALID_PARAMETER', u'DETAIL': u'Invalid parameter'}, u'URI': u'/key_command/'}

Of course I figure it out 5 seconds after I make the issue...url needs to be url = 'https://192.168.0.6:9000/key_command/'

exiva commented

Interesting. I just checked again and can leave the trailing slash off when using curl... But it is used in the SmartCast app, so I'll add it in the docs. 👍