Common Issues
API returns empty or unexpected results
API returns empty or unexpected results
Problem: Your query returns no data or results that don’t match expectations.Solutions:
- Verify variable names - Variable codes are case-sensitive. Check the table metadata to confirm exact spelling:
- Verify value names - Values must match exactly as they appear in the metadata:
- Include all required variables - Some tables require selections for all variables. If in doubt, use the
"all"filter:
Connection timeout or network errors
Connection timeout or network errors
Problem: Requests fail with timeout or connection errors.Solutions:
- Increase timeout - Large tables may take longer to process:
- Check API availability - Verify the API is accessible:
- Reduce query size - Request smaller subsets of data instead of entire tables:
Invalid JSON error
Invalid JSON error
Problem: API returns an error about invalid JSON format.Solutions:
- Verify JSON structure - Ensure your query list follows the correct format:
- Check for special characters - Some variable values may contain special characters. Use exact strings from metadata.
- Validate with jsonlite - Test your JSON structure:
Table not found or 404 error
Table not found or 404 error
Problem: API returns a 404 error when trying to access a table.Solutions:
- Verify the path - Double-check each level of the hierarchy:
- Check spelling and spacing - Folder and table names are case-sensitive and must match exactly.
-
Confirm table extension - Tables must end in
.px
Data parsing errors when reading CSV
Data parsing errors when reading CSV
Problem:
read_csv() fails to parse the API response correctly.Solutions:- Check response status - Verify you received data:
- Inspect raw response - Look at the actual data returned:
- Adjust CSV parsing options - Some tables may need different settings:
Missing packages or dependencies
Missing packages or dependencies
Problem: Required R packages are not installed.Solutions:Install required packages:Load packages at the start of your script:
Helper function build_url() not working
Helper function build_url() not working
Problem: The
build_url() helper function returns errors or unexpected results.Solutions:- Verify function definition - Ensure the complete function is defined:
- Check purrr is loaded - The function requires
purrrfrom tidyverse:
Getting Additional Help
PxWeb Documentation
Review the official PxWeb API specification
Available Databases
Check the list of available databases and their structure