René's URL Explorer Experiment


Title: BatchRequestBuilder doesn't copy headers from BatchRequestContent on post · Issue #831 · microsoftgraph/msgraph-sdk-python-core · GitHub

Open Graph Title: BatchRequestBuilder doesn't copy headers from BatchRequestContent on post · Issue #831 · microsoftgraph/msgraph-sdk-python-core

X Title: BatchRequestBuilder doesn't copy headers from BatchRequestContent on post · Issue #831 · microsoftgraph/msgraph-sdk-python-core

Description: Describe the bug I'm trying to send a batch request from UsersRequestBuilder and GroupsRequestBuilder objects that use the ConsistencyLevel: eventual header. The RequestInformation objects loaded in the BatchRequestContent include the he...

Open Graph Description: Describe the bug I'm trying to send a batch request from UsersRequestBuilder and GroupsRequestBuilder objects that use the ConsistencyLevel: eventual header. The RequestInformation objects loaded i...

X Description: Describe the bug I'm trying to send a batch request from UsersRequestBuilder and GroupsRequestBuilder objects that use the ConsistencyLevel: eventual header. The RequestInformation objects load...

Opengraph URL: https://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"BatchRequestBuilder doesn't copy headers from BatchRequestContent on post","articleBody":"### Describe the bug\n\nI'm trying to send a batch request from `UsersRequestBuilder` and `GroupsRequestBuilder` objects that use the `ConsistencyLevel: eventual` header. The `RequestInformation` objects loaded in the `BatchRequestContent` include the header, but then when calling to the `post` method of the `BatchRequestBuilder` it doesn't copy the headers, just creates the `Content-Type` header, resulting on a 400 error from the server.\n\nThe bug itself is in the following lines:\n\nhttps://github.com/microsoftgraph/msgraph-sdk-python-core/blob/df7bdbfb7e4268df10606f2b35623ecff559fe00/src/msgraph_core/requests/batch_request_builder.py#L126-L135\n\n### Expected behavior\n\nThe `to_post_request_information` method from `BatchRequestBuilder` should copy the headers from the provided `BatchRequestContent` object\n\n### How to reproduce\n\nYou can reproduce it using the following snippet\n\n```Python\nimport base64\n\nfrom typing import Optional\n\nfrom azure.keyvault.secrets import SecretClient\nfrom azure.identity import CertificateCredential, ManagedIdentityCredential\nfrom kiota_abstractions.base_request_configuration import RequestConfiguration\nfrom msgraph.generated.users.users_request_builder import UsersRequestBuilder\nfrom msgraph.graph_service_client import GraphServiceClient\nfrom msgraph_core.requests.batch_request_builder import BatchRequestBuilder\nfrom msgraph_core.requests.batch_request_content import BatchRequestContent\nfrom msgraph_core.requests.batch_request_item import BatchRequestItem\n\n\ndef get_tenant_credential(tenant_id, client_id, cert_name):\n    url = \"https://\u003cYOUR VAULT URL\u003e.vault.azure.net/\"\n    credential = ManagedIdentityCredential(\n        client_id=\"\u003cYOUR CLIENT ID\u003e\"\n    )\n    key_vault_client = SecretClient(vault_url=url, credential=credential)\n    secret = key_vault_client.get_secret(cert_name).value\n    cert_bytes = base64.b64decode(secret)\n    return CertificateCredential(\n        tenant_id=tenant_id,\n        client_id=client_id,\n        certificate_data=cert_bytes,\n        send_certificate_chain=True\n    )\n\n\ndef get_graph_client():\n    tenant = \"\u003cYOUR TENANT\u003e\"\n    client_id = \"\u003cYOUR GRAPH CLIENT ID\u003e\"\n    cert_name = \"\u003cYOUR GRAPH CERT NAME\u003e\"\n    credential = get_tenant_credential(tenant, client_id, cert_name)\n    scopes = [\"https://graph.microsoft.com/.default\"]\n    return GraphServiceClient(credential, scopes)\n\n\ndef build_query_filters(\n    domains: list[str],\n    fields: Optional[list[str]] = None,\n    search_term: Optional[str] = None,\n    excluded_ids: Optional[set[str]] = None,\n) -\u003e str:\n    filter_list = [f\"endswith(mail, '@{d}')\" for d in domains]\n    filters = f\"({' or '.join(filter_list)})\"\n\n    if search_term:\n        if fields is None:\n            fields = ['displayName', 'mail']\n\n        search_filter_list = [f\"startswith({f}, '{search_term}')\"\n                              for f in fields]\n        search_filters = f\"({' or '.join(search_filter_list)})\"\n        filters = f\"{filters} and {search_filters}\"\n\n    if excluded_ids:\n        exclusion_list = [f\"id ne '{i}'\" for i in excluded_ids]\n        excluded_filter = f\"{' and '.join(exclusion_list)}\"\n        filters = f\"{filters} and {excluded_filter}\"\n    return filters\n\n\ndef build_users_request_config(\n    search_term: Optional[str] = None,\n    n_items: Optional[int] = None,\n    excluded_ids: Optional[set[str]] = None,\n) -\u003e RequestConfiguration:\n    domains = [\"microsoft.com\", \"linkedin.biz\", \"*.microsoft.com\"]\n    filters = build_query_filters(\n        domains,\n        search_term=search_term,\n        excluded_ids=excluded_ids,\n    )\n    query_params = UsersRequestBuilder.UsersRequestBuilderGetQueryParameters(\n        select=['id', 'displayName', 'mail'],\n        filter=filters,\n        top=n_items,\n        count=True,\n    )\n    request_config = RequestConfiguration(query_parameters=query_params)\n    request_config.headers.add(\"ConsistencyLevel\", \"eventual\")\n    return request_config\n\n\nasync def search(search_term: str, n_items: int = 5):\n    client = get_graph_client()\n    request_adapter = client.request_adapter\n\n    # Build user request batch item\n    user_request_config = build_users_request_config(search_term, n_items)\n    user_request_builder = UsersRequestBuilder(request_adapter, {})\n    user_request_info = user_request_builder.to_get_request_information(\n        user_request_config\n    )\n    user_request_item = BatchRequestItem(user_request_info)\n\n    # Build group request batch item\n    # group_request_config = build_groups_request_config(\n    #     search_term, n_items\n    # )\n    # group_request_builder = GroupsRequestBuilder(request_adapter, {})\n    # group_request_info = group_request_builder.to_get_request_information(\n    #     group_request_config\n    # )\n    # group_request_item = BatchRequestItem(group_request_info)\n\n    # Create batch request content\n    batch_request_content = BatchRequestContent({\n        user_request_item.id: user_request_item,\n        # group_request_item.id: group_request_item\n    })\n\n    batch_request_builder = BatchRequestBuilder(request_adapter)\n    batch_result = await batch_request_builder.post(batch_request_content)\n    return batch_result\n\n\nif __name__ == \"__main__\":\n    import asyncio\n\n    search_term = \"test\"\n    n_items = 5\n    loop = asyncio.get_event_loop()\n    results = loop.run_until_complete(search(search_term, n_items))\n    print(results)\n```\n\n### SDK Version\n\n1.15.0\n\n### Latest version known to work for scenario above?\n\n_No response_\n\n### Known Workarounds\n\nThere's no workaround possible, given the request information is created in the same method that send the post\n\n### Debug output\n\nERROR:root:API Error: \n        APIError\n        Code: 400\n        message: The server returned an unexpected status code and no error class is registered for this code 400\n\n### Configuration\n\n_No response_\n\n### Other information\n\n_No response_","author":{"url":"https://github.com/urucoder","@type":"Person","name":"urucoder"},"datePublished":"2025-02-12T23:31:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/831/msgraph-sdk-python-core/issues/831"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e92ecb24-21d8-192c-ebeb-1ca87aaab663
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB7C2:123AEB:43D8F:5797F:6969C322
html-safe-nonce0ceb6ffef1e5d90eb8550356e9d0fc9b16787fc36f8edfd438954295420db5ac
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCN0MyOjEyM0FFQjo0M0Q4Rjo1Nzk3Rjo2OTY5QzMyMiIsInZpc2l0b3JfaWQiOiIxNDg4NTE0NDU4MjkwMDc4NDk4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacd9917b1048158078fd1e22d1197377c5c53e0201c1e150eaa92b080b9bad4116
hovercard-subject-tagissue:2849572678
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoftgraph/msgraph-sdk-python-core/831/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f9d1717532d41fa9729a03cd5cbff9b8f0d99866318650414fd51d60eeffc3f4/microsoftgraph/msgraph-sdk-python-core/issues/831
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f9d1717532d41fa9729a03cd5cbff9b8f0d99866318650414fd51d60eeffc3f4/microsoftgraph/msgraph-sdk-python-core/issues/831
og:image:altDescribe the bug I'm trying to send a batch request from UsersRequestBuilder and GroupsRequestBuilder objects that use the ConsistencyLevel: eventual header. The RequestInformation objects loaded i...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameurucoder
hostnamegithub.com
expected-hostnamegithub.com
Noneacedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056
turbo-cache-controlno-preview
go-importgithub.com/microsoftgraph/msgraph-sdk-python-core git https://github.com/microsoftgraph/msgraph-sdk-python-core.git
octolytics-dimension-user_id17304259
octolytics-dimension-user_loginmicrosoftgraph
octolytics-dimension-repository_id242847794
octolytics-dimension-repository_nwomicrosoftgraph/msgraph-sdk-python-core
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id242847794
octolytics-dimension-repository_network_root_nwomicrosoftgraph/msgraph-sdk-python-core
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release83c08c21cdda978090dc44364b71aa5bc6dcea79
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core%2Fissues%2F831
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core%2Fissues%2F831
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoftgraph%2Fmsgraph-sdk-python-core
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831
microsoftgraph https://github.com/microsoftgraph
msgraph-sdk-python-corehttps://github.com/microsoftgraph/msgraph-sdk-python-core
Notifications https://github.com/login?return_to=%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core
Fork 45 https://github.com/login?return_to=%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core
Star 277 https://github.com/login?return_to=%2Fmicrosoftgraph%2Fmsgraph-sdk-python-core
Code https://github.com/microsoftgraph/msgraph-sdk-python-core
Issues 15 https://github.com/microsoftgraph/msgraph-sdk-python-core/issues
Pull requests 16 https://github.com/microsoftgraph/msgraph-sdk-python-core/pulls
Discussions https://github.com/microsoftgraph/msgraph-sdk-python-core/discussions
Actions https://github.com/microsoftgraph/msgraph-sdk-python-core/actions
Projects 0 https://github.com/microsoftgraph/msgraph-sdk-python-core/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/microsoftgraph/msgraph-sdk-python-core/security
Please reload this pagehttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831
Insights https://github.com/microsoftgraph/msgraph-sdk-python-core/pulse
Code https://github.com/microsoftgraph/msgraph-sdk-python-core
Issues https://github.com/microsoftgraph/msgraph-sdk-python-core/issues
Pull requests https://github.com/microsoftgraph/msgraph-sdk-python-core/pulls
Discussions https://github.com/microsoftgraph/msgraph-sdk-python-core/discussions
Actions https://github.com/microsoftgraph/msgraph-sdk-python-core/actions
Projects https://github.com/microsoftgraph/msgraph-sdk-python-core/projects
Security https://github.com/microsoftgraph/msgraph-sdk-python-core/security
Insights https://github.com/microsoftgraph/msgraph-sdk-python-core/pulse
New issuehttps://github.com/login?return_to=https://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831
New issuehttps://github.com/login?return_to=https://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831
BatchRequestBuilder doesn't copy headers from BatchRequestContent on posthttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831#top
P1Priorityhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22P1%22
type:bugA broken experiencehttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22type%3Abug%22
https://github.com/urucoder
https://github.com/urucoder
urucoderhttps://github.com/urucoder
on Feb 12, 2025https://github.com/microsoftgraph/msgraph-sdk-python-core/issues/831#issue-2849572678
msgraph-sdk-python-core/src/msgraph_core/requests/batch_request_builder.pyhttps://github.com/microsoftgraph/msgraph-sdk-python-core/blob/df7bdbfb7e4268df10606f2b35623ecff559fe00/src/msgraph_core/requests/batch_request_builder.py#L126-L135
df7bdbfhttps://github.com/microsoftgraph/msgraph-sdk-python-core/commit/df7bdbfb7e4268df10606f2b35623ecff559fe00
P1Priorityhttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22P1%22
type:bugA broken experiencehttps://github.com/microsoftgraph/msgraph-sdk-python-core/issues?q=state%3Aopen%20label%3A%22type%3Abug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.