DataS-DHSC / fingertips_py

GNU General Public License v3.0
0 stars 0 forks source link

get_all_data_for_profile() #14

Open KarandeepKaur1 opened 6 months ago

KarandeepKaur1 commented 6 months ago

Getting the following error for get_all_data_for_profile()

raise InvalidURL(f"URL can't contain control characters. {url!r} "

InvalidURL: URL can't contain control characters. '/api/all_data/csv/by_profile_id?child_area_type_id=502 &parent_area_type_id=15&profile_id=19' (found at least ' ')

Tried:

profile_id=19 phof = ftp.get_all_data_for_profile(profile_id, area_type_id=502)

and

phof = ftp.get_all_data_for_profile(profile_id=19, area_type_id=502)

TM-LBH commented 3 months ago

I get a similar error:


InvalidURL Traceback (most recent call last) in <cell line: 2>() 1 #Add msoa area codes ----> 2 df_msoa = ftp.retrieve_data.get_all_data_for_profile(profile_id=profile, parent_area_type_id=401, area_type_id=3, filter_by_area_codes=areas_msoa, is_test=True) 3 dfs.append(df_msoa) 4 5 display(df_msoa)

17 frames /usr/lib/python3.10/http/client.py in _validate_path(self, url) 1226 match = _contains_disallowed_url_pchar_re.search(url) 1227 if match: -> 1228 raise InvalidURL(f"URL can't contain control characters. {url!r} " 1229 f"(found at least {match.group()!r})") 1230

InvalidURL: URL can't contain control characters. '/api/all_data/csv/by_profile_id?child_area_type_id=3 &parent_area_type_id=401&profile_id=32' (found at least ' ')

Looks like the request is including spaces where the second line of the fstrings formatted populated_url is indented. Changing it to the following will fix it: populated_url = f'all_data/csv/by_profile_id?child_area_type_id={area}' \ f'&parent_area_type_id={parent_area_type_id}&profile_id={profile_id}'