microsoftgraph / microsoftgraph/msgraph-sdk-python
BatchRequestItem use absolute url path instead of relative when, causing "Ressource not found" 400 error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 630
- Forks
- 96
- Avg merge
- 15h 20m
- Merged PRs (30d)
- 3
Description
Describe the bug
Here is my code :
batch_requests = BatchRequestContent()
for message_id in message_ids:
query_params = MessagesRequestBuilder.MessagesRequestBuilderGetQueryParameters(
select=[
'id',
'conversationId',
'internetMessageId',
'subject',
'body',
'bodyPreview',
'from',
'toRecipients',
'ccRecipients',
'bccRecipients',
'receivedDateTime',
'sentDateTime',
'internetMessageHeaders',
'isRead',
'isDraft',
'importance',
'hasAttachments',
'categories',
]
)
request_configuration = RequestConfiguration(
query_parameters=query_params
)
request = service.me.messages.by_message_id(message_id).to_get_request_information(
request_configuration=request_configuration
)
request_id = str(uuid.uuid4())
batch_request_item = BatchRequestItem(id=request_id, request_information=request)
# batch_request_item.url = batch_request_item.url.replace('https://graph.microsoft.com/v1.0', '')
batch_requests.add_request(request_id=request_id, request=batch_request_item)
Without the line I've commented, it causes a 400 "Resource not found for the segment 'https:'".
I figured out the problem by looking at your code.
I guess it is not the behavior as you intended.
Expected behavior
The server answer a code HTTP 200
How to reproduce
1 - List message ids from Outlook
2 - Try to get the email content in batch
SDK Version
No response
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing BatchRequestItem and BatchRequestContent.add_request using the Python example, then inspect how the request URL is constructed for batch operations. Verify the behavior with the Outlook message batch reproduction and confirm that the submitted item uses a relative path and receives HTTP 200 without the workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100