usaspending-api icon indicating copy to clipboard operation
usaspending-api copied to clipboard

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

Open jowg opened this issue 4 years ago • 2 comments

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)

jowg avatar Jul 13 '21 02:07 jowg

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

lisaam avatar Jul 15 '21 15:07 lisaam

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)

jowg avatar Jul 21 '21 03:07 jowg