<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def create_ondemand_streaming_locator(access_token, encoded_asset_id, pid, starttime=None):
    '''Create Media Service OnDemand Streaming Locator.

    Args:
        access_token (str): A valid Azure authentication token.
        encoded_asset_id (str): A Media Service Encoded Asset ID.
        pid (str): A Media Service Encoded PID.
        starttime (str): A Media Service Starttime.

    Returns:
        HTTP response. JSON body.
    '''
    path = '/Locators'
    endpoint = ''.join([ams_rest_endpoint, path])
    if starttime is None:
        body = '{ \
			"AccessPolicyId":"' + pid + '", \
			"AssetId":"' + encoded_asset_id + '", \
			"Type": "2" \
    }'
    else:
        body = '{ \
			"AccessPolicyId":"' + pid + '", \
			"AssetId":"' + encoded_asset_id + '", \
			"StartTime":"' + str(starttime) + '", \
			"Type": "2" \
		}'
    return do_ams_post(endpoint, path, body, access_token, "json_only")