Repository: microsoftgraph/msgraph-sdk-python-core

Issue:
Batch requests are not replacing token placeholders in request URLs, resulting in bad payloads
@shemogumbe 
To reproduce:

```python
# Use the request builder to generate a regular
# request to /me
user_request = graph_client.me.to_get_request_information()

today = datetime.today()
tomorrow = today + timedelta(days=1)

# Use the request builder to generate a regular
# request to /me/calendarview?startDateTime="start"&endDateTime="end"
query_params = CalendarViewRequestBuilder.CalendarViewRequestBuilderGetQueryParameters(
    start_date_time=today.isoformat(timespec='seconds'),
    end_date_time=tomorrow.isoformat(timespec='seconds')
)

config = CalendarViewRequestBuilder.CalendarViewRequestBuilderGetRequestConfiguration(
    query_parameters=query_params
)
events_request = graph_client.me.calendar_view.to_get_request_information(config)

# Build the batch
user_batch_item = BatchRequestItem(request_information=user_request)
events_batch_item = BatchRequestItem(request_information=events_request)
batch_request_content = BatchRequestContentCollection()
batch_request_content.add_batch_request_item(user_batch_item)
batch_request_content.add_batch_request_item(events_batch_item)

# Create batch request builder (temporary?)
batch_request_builder = BatchRequestBuilder(request_adapter=graph_client.request_adapter)

batch_response = await batch_request_builder.post(batch_request_content)
```

This results in the following payload going over the wire. Note the `users/me-token-to-replace` in the URLs - this should have been updated to `/me`.

```json
[
  {
    "id": "1c4593e4-b600-4945-85bf-d58f552ae414",
    "url": "https://graph.microsoft.com/v1.0/users/me-token-to-replace",
    "depends_on": []
  },
  {
    "id": "e4bb3047-d4eb-4ed6-b051-7f21a13f3f5f",
    "url": "https://graph.microsoft.com/v1.0/users/me-token-to-replace/calendarView?endDateTime=2024-09-26T14%3A12%3A59&startDateTime=2024-09-25T14%3A12%3A59",
    "depends_on": []
  }
]
```

Similar issue was in the Go SDK: https://github.com/microsoftgraph/msgraph-sdk-go-core/issues/179.

Hints from issue comments:

Solution patch:
diff --git a/src/msgraph_core/requests/batch_request_item.py b/src/msgraph_core/requests/batch_request_item.py
index e5f46e8..61fa480 100644
--- a/src/msgraph_core/requests/batch_request_item.py
+++ b/src/msgraph_core/requests/batch_request_item.py
@@ -42,7 +42,7 @@ class BatchRequestItem(Parsable):
         self.method = request_information.http_method
         self._headers = request_information.request_headers
         self._body = request_information.content
-        self.url = request_information.url
+        self.url = request_information.url.replace('/users/me-token-to-replace', '/me', 1)
         self._depends_on: Optional[List[str]] = []
         if depends_on is not None:
             self.set_depends_on(depends_on)
@@ -101,7 +101,7 @@ class BatchRequestItem(Parsable):
                 f"Error occurred during regex replacement of API version in URL string: {url}"
             )
 
-        relative_url = re.sub(self.ME_TOKEN_REGEX, '/me', relative_url, 1)
+        relative_url = relative_url.replace('/users/me-token-to-replace', '/me', 1)
         if not relative_url:
             raise ValueError(
                 f"""Error occurred during regex replacement


Test patch:
diff --git a/tests/requests/test_batch_request_item.py b/tests/requests/test_batch_request_item.py
index f70c40f..4b14b48 100644
--- a/tests/requests/test_batch_request_item.py
+++ b/tests/requests/test_batch_request_item.py
@@ -50,6 +50,43 @@ def test_set_url(batch_request_item):
     assert batch_request_item.url == "/v1.0/me"
 
 
+def test_constructor_url_replacement():
+    request_info = RequestInformation()
+    request_info.http_method = "GET"
+    request_info.url = "https://graph.microsoft.com/v1.0/users/me-token-to-replace"
+    request_info.headers = RequestHeaders()
+    request_info.content = None
+
+    batch_request_item = BatchRequestItem(request_info)
+
+    assert batch_request_item.url == "https://graph.microsoft.com/v1.0/me"
+
+
+def test_set_url_replacement():
+    request_info = RequestInformation()
+    request_info.http_method = "GET"
+    request_info.url = "https://graph.microsoft.com/v1.0/users/me-token-to-replace"
+    request_info.headers = RequestHeaders()
+    request_info.content = None
+
+    batch_request_item = BatchRequestItem(request_info)
+    batch_request_item.set_url("https://graph.microsoft.com/v1.0/users/me-token-to-replace")
+
+    assert batch_request_item.url == "/v1.0/me"
+
+
+def test_constructor_url_replacement_with_query():
+    request_info = RequestInformation()
+    request_info.http_method = "GET"
+    request_info.url = "https://graph.microsoft.com/v1.0/users/me-token-to-replace?param=value"
+    request_info.headers = RequestHeaders()
+    request_info.content = None
+
+    batch_request_item = BatchRequestItem(request_info)
+
+    assert batch_request_item.url == "https://graph.microsoft.com/v1.0/me?param=value"
+
+
 def test_id_property(batch_request_item):
     batch_request_item.id = "new_id"
     assert batch_request_item.id == "new_id"