Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Download Tool, Can't Replicate Same Results

hellyars
13 - Pulsar

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

 

 

Screenshot 2023-04-27 165648.png

 

 

Workflow attached:

 

 

 

 

 

3 REPLIES 3
ArnaldoSandoval
12 - Quasar

Hi @hellyars 

 

Your workflow was almost working, I found 2 or 3 glitches.

 

Glitches:

  • The URL in your Text Input failed to work with the working stream you will find in the attached workflow; I copied the URL from my testing tool, Postman.

 USA_Spending_API_01.png

  • Your download tool's parameter "Content-Type" should be without the double quotes, the same with its value:

USA_Spending_API_02.png

  • Your download tool's Payload configuration is not correct; you created a parameter "json" which confused the whole process; you should use the bottom option "Use Following Query String/Body"

USA_Spending_API_03.png

The Body of the request here is in JSon, but do not paster pretty formatted JSon, just the whole JSon string.

USA_Spending_API_04.png

 

Suggestions:

  • The USA Spending API page documentation is a bit complicated or unfriendly, it took me a while to figure out the command to use in the script.
  • Please watch this video: API's in Alteryx ; it is a 25 minutes demo implementing API calls in Alteryx.
  • The video above direct you to Postman which is a great tool to test API calls before coding them into Alteryx; I used this tool when playing with the USA Spending APIs.

Attached the working solution:

 

Hope this helps,

Arnaldo

 

hellyars
13 - Pulsar

@ArnaldoSandoval  

 

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)?

 

 

 

ArnaldoSandoval
12 - Quasar

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.

Labels