If roleNames.Count is 1, then it tries to call with roleName, not roleNames[0].   roleName contains a wildcard, so it will throw an exception during the REST call.