msgraph-sdk-python-core
msgraph-sdk-python-core copied to clipboard
get returns all fields, select provides values, all non selected fields returned with 'None' value
Environment
- Python Version: 3.11.6
- msgraph-core version: 1.0.0.a4
- OS: MacOS 14.2.1 M2
Stack trace (if available)
Screenshot or formatted copy and paste of your stack trace.
Describe the bug formatting a select statement
query_params = UsersRequestBuilder.UsersRequestBuilderGetQueryParameters(
select=['id', 'accountEnabled', 'businessPhones', 'city', 'companyName', 'country', 'createdDateTime',
'deletedDateTime', 'department', 'displayName', 'employeeId', 'givenName', 'jobTitle',
'mail', 'mailNickname', 'mobilePhone', 'officeLocation', 'postalCode', 'preferredDataLocation',
'preferredLanguage', 'securityIdentifier', 'state', 'streetAddress', 'surname', 'userPrincipalName',
'userType'],
orderby= "displayName",
top=1
)
request_configuration = UsersRequestBuilder.UsersRequestBuilderGetRequestConfiguration(
query_parameters=query_params
)
request_configuration.headers.add('ConsistencyLevel', 'eventual')
users = await client.users.get(request_configuration = request_configuration)
This returns:
UserCollectionResponse(
additional_data={'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#users(id,accountEnabled,businessPhones,city,companyName,country,createdDateTime,deletedDateTime,department,displayName,employeeId,givenName,jobTitle,mail,mailNickname,mobilePhone,officeLocation,postalCode,preferredDataLocation,preferredLanguage,securityIdentifier,state,streetAddress,surname,userPrincipalName,userType)'},
odata_count=17,
odata_next_link='https://graph.microsoft.com/v1.0/users?$top=1&$count=true&$orderby=displayName&$select=id%2caccountEnabled%2cbusinessPhones%2ccity%2ccompanyName%2ccountry%2ccreatedDateTime%2cdeletedDateTime%2cdepartment%2cdisplayName%2cemployeeId%2cgivenName%2cjobTitle%2cmail%2cmailNickname%2cmobilePhone%2cofficeLocation%2cpostalCode%2cpreferredDataLocation%2cpreferredLanguage%2csecurityIdentifier%2cstate%2cstreetAddress%2csurname%2cuserPrincipalName%2cuserType&$skiptoken=m~AQC4ATs7MzAwMDQ1MDAzMDAwMzIwMDMwMDA0NTAwMzEwMDQxMDAzMDAwNDUwMDMyMDAzMTAwMzAwMDQ1MDAzNDAwMzgwMDMwMDA0NTAwMzIwMDMxMDAzMDAwMzcwMDMwMDAzMjAwMzAwMDQ1MDA0MTAwMzIwMDMwMDA0NTAwMzAwMDMyMDAzMDAwNDUwMDM3MDAzMDAwMzAwMDQ1MDAzMDAwNDEwMDMwMDA0NTAwMzIwMDMxMDA7MTswOzs',
value=[
User(
additional_data={},
id='4421ec16-6e81-436e-b765-8ab20ef1fdc7',
odata_type='#microsoft.graph.user',
deleted_date_time=None,
about_me=None,
account_enabled=True,
activities=None,
age_group=None,
agreement_acceptances=None,
app_role_assignments=None,
assigned_licenses=None,
assigned_plans=None,
authentication=None,
authorization_info=None,
birthday=None,
business_phones=['+1 425 555 0109'],
calendar=None,
calendar_groups=None,
calendar_view=None,
calendars=None,
chats=None,
city='Bellevue',
company_name=None,
consent_provided_for_minor=None,
contact_folders=None,
contacts=None,
country='United States',
created_date_time=DateTime(2023, 11, 7, 11, 32, 41, tzinfo=Timezone('UTC')),
created_objects=None,
creation_type=None,
custom_security_attributes=None,
department='Retail',
device_enrollment_limit=None,
device_management_troubleshooting_events=None,
direct_reports=None,
display_name='Adele Vance',
drive=None,
drives=None,
employee_experience=None,
employee_hire_date=None,
employee_id=None,
employee_leave_date_time=None,
employee_org_data=None,
employee_type=None,
events=None,
extensions=None,
external_user_state=None,
external_user_state_change_date_time=None,
fax_number=None,
followed_sites=None,
given_name='Adele',
hire_date=None,
identities=None,
im_addresses=None,
inference_classification=None,
insights=None,
interests=None,
is_resource_account=None,
job_title='Retail Manager',
joined_teams=None,
last_password_change_date_time=None,
legal_age_group_classification=None,
license_assignment_states=None,
license_details=None,
mail='[email protected]',
mail_folders=None,
mail_nickname='AdeleV',
mailbox_settings=None,
managed_app_registrations=None,
managed_devices=None,
manager=None,
member_of=None,
messages=None,
mobile_phone=None,
my_site=None,
oauth2_permission_grants=None,
office_location='18/2111',
on_premises_distinguished_name=None,
on_premises_domain_name=None,
on_premises_extension_attributes=None,
on_premises_immutable_id=None,
on_premises_last_sync_date_time=None,
on_premises_provisioning_errors=None,
on_premises_sam_account_name=None,
on_premises_security_identifier=None,
on_premises_sync_enabled=None,
on_premises_user_principal_name=None,
onenote=None,
online_meetings=None,
other_mails=None,
outlook=None,
owned_devices=None,
owned_objects=None,
password_policies=None,
password_profile=None,
past_projects=None,
people=None,
photo=None,
photos=None,
planner=None,
postal_code='98004',
preferred_data_location=None,
preferred_language='en-US',
preferred_name=None,
presence=None,
print=None,
provisioned_plans=None,
proxy_addresses=None,
registered_devices=None,
responsibilities=None,
schools=None,
scoped_role_member_of=None,
security_identifier='S-1-12-1-1143073814-1131410721-2995414453-3355308302',
service_provisioning_errors=None,
settings=None,
show_in_address_list=None,
sign_in_activity=None,
sign_in_sessions_valid_from_date_time=None,
skills=None,
state='WA',
street_address='205 108th Ave. NE, Suite 400',
surname='Vance',
teamwork=None,
todo=None,
transitive_member_of=None,
usage_location=None,
user_principal_name='[email protected]',
user_type='Member'
)
]
)
To Reproduce Use the code above, it works across every object I have used so far.
Expected behavior I would expect to just get the 26 fields I selected.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Hi @dogrileycom, thanks for reaching out.
This happens because we're initialising a User object whose properties default to None. The HTTP response only returns the selected fields.
Would you mind sharing more context/a use-case where you'd prefer an object with only the 26 fields?
In the Graph SDK all properties are marked as Optional[type] which have None as value of unset.
To me seeing all those fields with a None value is exactly what I would expect if I don't select them. All models are strong typed User in this case. I guess you @dogrileycom
were expecting to get a dynamic object or dictionary to be returned?
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.