Я получаю данные из запроса следующим образом
[
{
"Info": {
"SoftwareVersion": "111",
"IpAddress": "111.111.11",
"DeviceName": "1111222",
"Type": "Tablet"
},
"DeviceIdentity": "Identity",
"AdmissionGuid": "db128362-f942-47fb-b18e-c073aa03b95d",
"UserId": "8c7be5ac-9f2e-42aa-8f17-4e935a85eff3",
"ConnectionId": "f78f544e-0780-4b07-87ec-d4edbe4cb522",
"PairingId": null
}
]
Затем я пытаюсь разобрать его в Python, все работает, я получаю значение, как и ожидалось, но я получаю следующую ошибку, я пытался преобразоватьэто Object, String, Hex, но ничего не работает
Ошибка преобразования значения "AdmissionGuid" в System.GUID
Python-скрипт
from requests import Session
from signalr import Connection
import threading, time, json, logging
import urllib.request
import requests
import uuid
GetPatientID = requests.get('http://example-url.com/api/json')
data = GetAdmissionID.json()
print (type(data))
AdmissionGuid= uuid.UUID(data[0]["AdmissionGuid"])
print (type(AdmissionGuid))
UserID = "8c7be5ac-9f2e-42aa-8f17-4e935a85eff3"
softwareVersion = "111"
IpAddress = "111.111.11"
machineName = "1111222"
DeviceType = "Tablet"
pairingId = "null"
def __init__(self, cli):
self.cli = cli
logging.info("registered the cli (main thread)")
with Session() as session:
connection = Connection("http://example-url.com/signalr", session)
print(connection)
logging.info("got the connection")
presenceservice = connection.register_hub('ClientRegistration')
logging.info("got the hub")
connection.start()
def get_data(notificaition):
print("Recived something?: ", notificaition)
def print_error(error):
print('error: ', error)
connection.error += print_error
presenceservice.server.invoke('IdentifyClient', 'devideIdentity', 'softwareVersion', 'ipAddress',
'machineName', 'deviceType', 'patientAdmissionGuid', 'patientId', 'pairingId')
key = input("Press E\n")
if key == 'e':
connection.wait(1)
presenceservice.client.on('Notification', get_data)
print ('Nothing Happned')
connection.wait(30)
Иthe log
<class 'list'>
<class 'uuid.UUID'>
Press E
e
error: Error converting value "AdmissionGuid" to type 'System.Guid'.
Примечание: я также использую библиотеку Singal R для вызова C # Hub для регистрации клиента.
AdmissionGuid
Генерируется в C # с использованием библиотеки GUID,
Есть ли способ попасть в python?
Я уже посмотрел на это 1 , 2 , но это не решает мою проблему
РЕДАКТИРОВАТЬ C # Функция я звоню с Singal R
IdentifyClient(string devideIdentity, string softwareVersion, string ipAddress, string machineName, string deviceType, Guid AdmissionGuid, Guid UserID, string pairingId)