我想獲得釋放級數使用八達通客戶端(github source)調用/api/progression/<project-id>
端點這樣一個特定的項目:八達通客戶端無法解析部署字典中ReleaseProgressionResource
// _repository is of type IOctopusRepository
_repository.Client.Get<ProgressionResource>($"/api/progression/{projectId}");
這是立即拋出OctopusDeserializationException
說:
無法處理從服務器響應:不能反序列化當前 JSON對象(例如{「名稱」:「值」})到 類型「System.Linq.IOrderedEnu merable`1 [Octopus.Client.Model.DashboardItemResource]' ,因爲該類型需要JSON數組(例如, [1,2,3])正確地反序列化 。 要解決此錯誤,請將JSON更改爲JSON數組(例如[1,2,3])或更改反序列化類型,以便它是一個正常的.NET類型(例如,不是像integer這樣的基本類型,也不是集合鍵入 就像數組或列表),可以從JSON對象反序列化。 也可以將JsonObjectAttribute添加到該類型中,以強制它從一個JSON對象反序列化爲 。 Path'Releases [0] .Deployments.Environments-1.Id',line 55,position 15 .. Response content:{ 「Environments」:[ {Id}:「Environments-1」, 「Name 「:‘從
Releases
測試環境’ },
在各推出(ReleaseProgressionResource
類型)有一個Deployments
丙是Dictionary<string,IOrderedEnumerable<DashboardItemResource>>
類型。但是,似乎客戶端(已經被使用這個API)不能序列化。從異常消息看來,客戶端似乎試圖將其解析爲JSON數組。
這裏的原始JSON端點響應的樣品Deployments
部分(有一些虛擬數據):
"Deployments": {
"Environments-1": {
"Id": "Deployments-12345",
"ProjectId": "Projects-123",
"EnvironmentId": "Environments-1",
"ReleaseId": "Releases-12345",
"DeploymentId": "Deployments-12345",
"TaskId": "ServerTasks-12345",
"ReleaseVersion": "5.4.3",
"Created": "2016-09-22T21:26:38.886+00:00",
"QueueTime": "2016-09-22T21:26:38.855+00:00",
"CompletedTime": "2016-09-22T21:29:48.355+00:00",
"State": "Success",
"HasPendingInterruptions": false,
"HasWarningsOrErrors": false,
"ErrorMessage": "",
"Duration": "3 minutes",
"IsCurrent": true,
"IsPrevious": false,
"IsCompleted": true,
"Links": {
"Self": "/api/deployments/Deployments-12345",
"Release": "/api/releases/Releases-12345",
"Task": "/api/tasks/ServerTasks-12345"
}
}
}
沒有人有任何想法什麼可能發生的/我可能是做錯了什麼? 在此先感謝。
沒有這只是它未能序列化的部分。這是一個更大結構的一部分。我獲取'ProgressionResource',其中包含'ReleaseProgressionResources'集合,其中包含此部署失敗的'Deployments'字典,因爲反序列化器試圖將其解析爲名爲'Environments-1'屬性的對象作爲一個字典。 – valorl