bug in teams api - The navigation bind for template was missing in request
python environment:
msgraph-core 1.0.0a4 pypi_0 pypi
msgraph-sdk 1.0.0 pypi_0 pypi
Trying to add a new team with a very basic example from the general api documentation:
from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient
from msgraph.generated.models.team import Team
import asyncio
import os
from dotenv import load_dotenv
load_dotenv('./secrets.env')
tenant_id = os.getenv("tenant_id")
client_id = os.getenv("client_id")
secret = os.getenv("secret")
credential = ClientSecretCredential(tenant_id, client_id, secret)
scopes = ['https://graph.microsoft.com/.default']
graph_client = GraphServiceClient(credentials=credential, scopes=scopes)
request_body = Team(
display_name = "My Sample Team",
description = "My Sample Team’s Description",
additional_data = {
"template@odata_bind" : "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
}
)
result = asyncio.run(graph_client.teams.post(request_body))
print(result)
This is failing with a "The navigation bind for template was missing in request."
msgraph.generated.models.o_data_errors.o_data_error.ODataError:
APIError
Code: 400
message: None
error: MainError(additional_data={}, code='BadRequest', details=None, inner_error=InnerError(additional_data={'code': 'InvalidRequest', 'message': 'The navigation bind for template was missing in request.', 'details': [], 'date': DateTime(2023, 12, 28, 14, 44, 38, tzinfo=Timezone('UTC'))}, client_request_id='32570803-a3c7-4ab3-ae92-9c74b21d6671', date=None, odata_type=None, request_id='96b60448-1655-4c0c-a2c9-cc9b7c0d6c2e'), message='The navigation bind for template was missing in request.', target=None)
I also have the same issue
I've found the issue, there is a problem in the docs, the key template@odata_bind should be [email protected].
However, there is another issue, once the Team gets created the resulting object is not returned and you receive None instead.
The Documentation of the API defines that it should return a Content-Location header containing the created team id and an empty body, however, the SDK returns True on self._should_return_none(response) on HttpxRequestAdapter.send_async and does not return the Team data or the team id.
Hi @almeida-raphael, Thanks for trying the SDK. As you have discovered, the Teams api and the response is not a Team object, You will need to use a header inspection handler to read the response headers
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.