Python Add Address to Stream SDK URLLIB3 error

The python code in the example: https://moralisweb3.github.io/Moralis-Python-SDK/streams/evm_streams.html#add_address_to_stream

keeps raising the error: urllib3.exceptions.LocationValueError: No host specified. And I can not add an address to an existing stream. Can you help me fix this issue?

My code:

from moralis import streams

api_key = "..."
params = {
"id": "7fcc3853-7bbe-47d2-b33b-631e528a0435",
}
body = {
"address": "0x9bf248b75d1bc24bc94822be2d2f0a2afc333e6b",
}

result = streams.evm_streams.add_address_to_stream(
api_key=api_key,
params=params,
body=body,
)

Error:

LocationValueError Traceback (most recent call last)
Cell In[1], line 11
4 params = {
5 "id": "7fcc3853-7bbe-47d2-b33b-631e528a0435",
6 }
7 body = {
8 "address": "0x9bf248b75d1bc24bc94822be2d2f0a2afc333e6b",
9 }
---> 11 result = streams.evm_streams.add_address_to_stream(
12 api_key=api_key,
13 params=params,
14 body=body,
15 )
17 print(result)

File ~/Documents/projects/cloud-functions/env/lib/python3.9/site-packages/moralis/streams/evm_streams/add_address_to_stream.py:17, in add_address_to_stream(api_key, params, body)
15 api_instance = get_api_instance(api_key, params)
16 path_params: typing.Any = {k: v for k, v in params.items() if k in RequestPathParams.__annotations__.keys()}
---> 17 api_response = api_instance.add_address_to_stream(
18 body=body,
19 path_params=path_params,
20 accept_content_types=(
21 'application/json; charset=utf-8',
22 ),
23 skip_deserialization=True
24 )
26 return json.loads(api_response.response.data)

File ~/Documents/projects/cloud-functions/env/lib/python3.9/site-packages/openapi_streams/paths/streams_evm_id_address/post.py:302, in AddAddressToStream.add_address_to_stream(self, body, content_type, path_params, accept_content_types, stream, timeout, skip_deserialization)
292 def add_address_to_stream(
293 self,
294 body: typing.Union[SchemaForRequestBodyApplicationJson,],
(...)
300 skip_deserialization: bool = False,
301 ):
--> 302 return self._add_address_to_stream_oapg(
303 body=body,
304 path_params=path_params,
305 content_type=content_type,
306 accept_content_types=accept_content_types,
307 stream=stream,
308 timeout=timeout,
309 skip_deserialization=skip_deserialization
310 )

File ~/Documents/projects/cloud-functions/env/lib/python3.9/site-packages/openapi_streams/paths/streams_evm_id_address/post.py:207, in BaseApi._add_address_to_stream_oapg(self, body, content_type, path_params, accept_content_types, stream, timeout, skip_deserialization)
205 elif 'body' in serialized_data:
206 _body = serialized_data['body']
--> 207 response = self.api_client.call_api(
208 resource_path=used_path,
209 method='post'.upper(),
210 headers=_headers,
211 fields=_fields,
212 body=_body,
213 auth_settings=_auth,
214 stream=stream,
215 timeout=timeout,
216 )
218 if skip_deserialization:
219 api_response = api_client.ApiResponseWithoutDeserialization(response=response)

File ~/Documents/projects/cloud-functions/env/lib/python3.9/site-packages/openapi_streams/api_client.py:1139, in ApiClient.call_api(self, resource_path, method, headers, body, fields, auth_settings, async_req, stream, timeout, host)
1104 """Makes the HTTP request (synchronous) and returns deserialized data.
1105
1106 To make an async_req request, set the async_req parameter.
(...)
1135 then the method will return the response directly.
1136 """
1138 if not async_req:
-> 1139 return self.__call_api(
1140 resource_path,
1141 method,
1142 headers,
1143 body,
1144 fields,
1145 auth_settings,
1146 stream,
1147 timeout,
1148 host,
1149 )
1151 return self.pool.apply_async(
1152 self.__call_api,
1153 (
(...)
1164 )
1165 )

File ~/Documents/projects/cloud-functions/env/lib/python3.9/site-packages/openapi_streams/api_client.py:1080, in ApiClient.__call_api(self, resource_path, method, headers, body, fields, auth_settings, stream, timeout, host)
1077 url = host + resource_path
1079 # perform request and return response
-> 1080 response = self.request(
1081 method,
1082 url,
1083 headers=used_headers,
...
--> 236 raise LocationValueError("No host specified.")
238 request_context = self._merge_pool_kwargs(pool_kwargs)
239 request_context["scheme"] = scheme or "http"

LocationValueError: No host specified.

I have made sure to install the urllib3 version specified by the package:
urllib3==1.26.7
moralis==0.1.27

Hello, try a different version of the python SDK

Did it work to create a stream or other type of request with the python SDK?

Usually that error is because the deep index url is not set in the sdk, as in an issue with that version of the SDK.

Alternatively you can make a http request directly by following the example in the swagger interface:

https://api.moralis-streams.com/api-docs/#/EVM%20Streams/AddAddressToStream

Thanks @cryptokid for now I used the interface to construct the request myself. Do you know which ist the last version of the SDK that is working?

you can use this command to make it work now:

pip3.exe install moralis==0.1.19