ฉันต้องสร้างผู้ใช้ใหม่ใน Azure Devops โดยใช้ไลบรารีไคลเอ็นต์ python สำหรับ Azure DevOps REST API
ฉันเขียนโค้ดต่อไปนี้:
from azure.devops.connection import Connection
from azure.devops.v5_0.graph.models import GraphUserCreationContext
from msrest.authentication import BasicAuthentication
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
graph_client = connection.clients_v5_0.get_graph_client()
addAADUserContext = GraphUserCreationContext("[email protected]")
print(addAADUserContext)
resp = graph_client.create_user(addAADUserContext)
print(resp)
ฉันได้ผลลัพธ์:
{'additional_properties': {}, 'storage_key': '[email protected]'}
และมีข้อผิดพลาดเกิดขึ้นขณะเรียกใช้เมธอด create_user:
azure.devops.exceptions.AzureDevOpsServiceError: VS860015: Must have exactly one of originId or principalName set.
ที่จริงแล้วสิ่งที่ฉันควรส่ง GraphUserPrincipalNameCreationContext ไปยังฟังก์ชัน create_user
ฉันพบตัวอย่าง .NET ซึ่งทำสิ่งนี้ในฟังก์ชันชื่อ AddRemoveAADUserByUPN() : https://github.com/microsoft/azure-devops-dotnet-samples/blob/master/ClientLibrary/Samples/Graph/UsersSample.cs< /ก>
GraphUserPrincipalNameCreationContext คืออินเทอร์เฟซในตัวอย่างนี้ แต่หลามไม่รองรับอินเทอร์เฟซ
แล้วจะนำสิ่งนี้ไปใช้กับ python ได้อย่างไร?