Объект 'str' не имеет атрибута 'get_httpx_client'Python

Программы на Python
Anonymous
Объект 'str' не имеет атрибута 'get_httpx_client'

Сообщение Anonymous »


I am trying to access a specific endpoint in my REST API, one of my modules is passing a client URI into a module.sync_detailed (client, device). However, I get

AttributeError: 'str' object has no attribute 'get_httpx_client'

My code looks like

with client as client: my_data: MyDataModel = get_my_data_model.sync(client=client, device_id=device_id) response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client, device_id=device_id) I passed my localhost api and a dummy device_id in.

the sync_detailed function looks like this

def sync_detailed( *, client: Union[AuthenticatedClient, Client], device_id: str, ) -> Response[Any]: kwargs = _get_kwargs( device_id=device_id, ) response = client.get_httpx_client().request( **kwargs, ) return _build_response(client=client, response=response) I tried to check the type for client using print(type(client)) and got

The full error message looks like this:
AttributeError Traceback (most recent call last) in 6 with client: 7 # my_data: MyDataModel= await get_my_data_model.sync(client= 'http://localhost:3000/api') ----> 8 response: Response[MyDataModel] = await get_my_data_model.sync_detailed(client= 'http://localhost:3000/api', 9 device_id= '1234567890') ~/MyDataModel-initialization/MyDataModel_rest_api_client/api/default/get_my_data_model.py in sync_detailed(client, device_id) 67 ) 68 ---> 69 response = client.get_httpx_client().request( 70 **kwargs, 71 ) AttributeError: 'str' object has no attribute 'get_httpx_client'

Источник: https://stackoverflow.com/questions/780 ... tpx-client

Вернуться в «Python»