Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_all_data_for_profile() #14

Open
KarandeepKaur1 opened this issue Apr 12, 2024 · 1 comment
Open

get_all_data_for_profile() #14

KarandeepKaur1 opened this issue Apr 12, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@KarandeepKaur1
Copy link

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
Copy link

TM-LBH commented Jul 30, 2024

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}'

@Olivia-Box-Power Olivia-Box-Power added the bug Something isn't working label Sep 2, 2024
@Olivia-Box-Power Olivia-Box-Power self-assigned this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants