exiva / Vizio_SmartCast_API

API documentation for Vizio SmartCast TV's
173 stars 33 forks source link

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

Closed amblock closed 7 years ago

amblock commented 7 years ago

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/'}

amblock commented 7 years ago

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 7 years ago

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. 👍