fedspendingtransparency / usaspending-api

Server application to serve U.S. federal spending data via a RESTful API
https://www.usaspending.gov
Creative Commons Zero v1.0 Universal
308 stars 109 forks source link

Issues with https://api.usaspending.gov/api/v2/bulk_download/awards/ #3185

Open jowg opened 3 years ago

jowg commented 3 years ago

The following gives me a 500 error. No idea why. I don't think I'm missing any essentials...

    myurl = 'https://api.usaspending.gov/api/v2/bulk_download/awards/'
    mydata = {
        "filters": {
            "prime_award_types": ["A", "B", "C", "D"],
            "agency": "all",
            "date_type": "action_date",
            "date_range": {
                "start_date": "2019-10-01",
                "end_date": "2020-09-30"
            }
        }
    }
    r = requests.post(url = myurl,data = mydata)
lisaam commented 3 years ago

If you are using the USAspending API web page to run your query, the 500 error is a known issue.

We were able to send a successful request through a third-party application, Postman, with the following JSON query: {
"filters": { "prime_award_types": ["A", "B", "C", "D"], "agency": "all", "date_type": "action_date", "date_range":

{ "start_date": "2019-10-01", "end_date": "2020-09-30" } } }

jowg commented 3 years ago

I have figured this out. Evidently the payload needs to be passed to requests as json and not as data:

r = requests.post(url = myurl,json = mydata)