Add url alias with parameter (?foo=bar)
The reason you get that error is that the form validation handler verifies the source entered in the form is a valid menu path, using drupal_valid_path().

Setting the path alias directly in the database would cause errors, as the source of the path alias is used to set $GET['q'], in drupal_path_initialize(), which contains the following code.

$_GET['q'] = drupal_get_normal_path($_GET['q']);


In your case, $_GET['q'] would be set to mypath?foo=bar&amp;foo2=bar2. All the functions that use $_GET['q'] expect it to the in  the format path/subpath; the presence of the query parameters would cause errors. See for example the code executed by menu_get_item().

Using a custom module, you could implement hook_url_inbound_alter(), and hook_url_outbound_alter(). The first would transform foo/bar in mypath, setting $_GET['foo'] = 'bar', and $_GET['foo2'] = 'bar2'; the second would transform mypath in foo/bar, when $_GET['foo'] == 'bar', and $_GET['foo2'] == 'bar2'.