usaspending-api
usaspending-api copied to clipboard
Endpoint [/api/v2/bulk_download/awards/] prime_award_types parameter not optional?
Hi,
I am sending a POST request to the [/api/v2/bulk_download/awards/] endpoint with the following body:
body = '{ "filters": { "prime_award_types": ["IDV_A", "IDV_B", "IDV_B_A", "IDV_B_B", "IDV_B_C", "IDV_C", "IDV_D", "IDV_E", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "A", "B", "C", "D"], "agency": "all", "date_type": "action_date", "date_range": {"start_date":"2019-01-01", "end_date":"2019-12-31"} } }'
If I don't add the bolded section with prime_award_types I receive a 400 Bad Request error, even though it says prime_award_types is an optional parameter in the GitHub documentation? Am I missing something?
Thanks in advance, Nicolas
Hello Nicolas,
Thanks for letting us know! In this case, the term "optional" might be a little misleading. Because we perform automatic validation between our API contracts and API endpoints, we mark a parameter as "optional" as long as it's possible to make requests without it, even if there are other validation rules. In this case, the rule in the error message applies: either prime_award_types
or sub_award_types
must be present.
Thanks for the very quick reply Brian, I appreciate it!
I was mainly confused, since I tried an example from another user that worked with this body: body <- '{ "award_levels": ["prime_awards"], "filters": { "keyword": "009256819" }, "columns": ["action_date"], "file_format": "csv" }'
Does that work, because the keyword is functioning as another validation rule that can replace prime_award_types or sub_award_types?
Correct. Keyword actually nullifies all other filters: https://github.com/fedspendingtransparency/usaspending-api/blob/dev/usaspending_api/download/v2/year_limited_downloads.py#L30