Skip to content

Unable to connect to the settings API to get the timezone #51

Description

@Amit-GH

My skill is working fine except that it is not able to call the settings API successfully to get the timezone. I saw that this issue was mentioned in this closed issue too but was not fixed. I am pasting the line of code below that give error.

# get device id
device_id = handler_input.request_envelope.context.system.device.device_id

# get Alexa settings API information
sys_object = handler_input.request_envelope.context.system
api_endpoint = sys_object.api_endpoint
api_access_token = sys_object.api_access_token

# construct systems API timezone url
url = '{api_endpoint}/v2/devices/{device_id}/settings/System.timeZone'.format(
     api_endpoint=api_endpoint, device_id=device_id
)
headers = {'Authorization': 'Bearer ' + api_access_token}

userTimeZone = ""
try:
    r = requests.get(url, headers=headers)
    res = r.json()
    logger.info("Device API result: {}".format(str(res)))
    userTimeZone = res
except Exception as exp:
    logger.error('Got error in getting timezone: {}'.format(str(exp)))
    handler_input.response_builder.speak("There was a problem getting the timezone.")
    return handler_input.response_builder.response

My code always goes into the catch block. I have put a log statement there which prints Got error in getting timezone: Expecting value: line 1 column 1 (char 0) in cloudwatch.

Through this open pull-request I thought that the Settings API is not supported for Alexa simulator but the documentation states that getting timeZone is supported. So, I wonder what is the issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions