I want to use the Download Tool to replicate a USASpending.gov search. I know the results work. I am pointed to the correct endpoint and using the same JSON as the successful query, but I can't get it to work in Alteryx. Suspect, I do not have the Download Tool setup correctly. Thoughts?
Thanks...
See below, workflow also attached.
This is what I am trying to replicate the POST request used to generate these results. Link to results.
If you Inspect Network and Request you will see the following...
The API is
api.usaspending.gov
The Endpoint is
/api/v2/search/spending_by_award/
The JSON Request:
{"filters":{"keywords":["W56HZV"],"time_period":[{"start_date":"2021-10-01","end_date":"2022-09-30"}],"award_type_codes":["A","B","C","D"]},"fields":["Award ID","Recipient Name","Start Date","End Date","Award Amount","Description","def_codes","COVID-19 Obligations","COVID-19 Outlays","Infrastructure Obligations","Infrastructure Outlays","Awarding Agency","Awarding Sub Agency","Contract Award Type","recipient_id","prime_award_recipient_id"],"page":1,"limit":60,"sort":"Award Amount","order":"desc","subawards":false}
From Inspect Network double clicking the endpoint will generate and show the JSON results (which duplicates the results first reference above under link).
But I can't seem to get it to work using the Download tool.
I see two errors: 1) HTTP 1.1 422 Unpronounceable Entity and 2) {"detail":"Missing value: 'fields' is a required field"}
Workflow attached:
Solved! Go to Solution.
Hi @hellyars
Your workflow was almost working, I found 2 or 3 glitches.
Glitches:
The Body of the request here is in JSon, but do not paster pretty formatted JSon, just the whole JSon string.
Suggestions:
Attached the working solution:
Hope this helps,
Arnaldo
THANK YOU!!! I will watch the video as soon as I finish typing this response. I do have one question. The URLs appear to be the same (they join), so I don't understand why my URL failed to work (or was it just the culmination of the subsequent glitches/errors)?
Hi @hellyars
I can't understand that either, that is the reason I highlighted that in my comments, with your Text Input my download tool had issues with your URL, while it worked fine with mine, which visually looked exactly the same, perhaps your contains white spaces and the cleansing tool may resolve that issue.
Arnaldo.