Closed Monte307 closed 4 years ago
Try something like {"query":"cheddar cheese","pageNumber":1,"pageSize":1,"dataType":["Branded"]}
The spec is not clear but dataType needs to be represented as an array, i.e []. Also, the example on the website doesn't show this but you should include -XPOST in that cURL call.
Using a string array works for me thanks @littlebunch 😌
Also, for a GET request, a csv string should work: https://api.nal.usda.gov/fdc/v1/foods/list?sortBy=fdcId&sortOrder=asc&dataType=Foundation,Branded&pageSize=150&pageNumber=1&api_key=DEMO_KEY&format=abridged
that fixed it, thanks littlebunch!
This works (with a valid api key): curl -H "Content-Type:application/json" -d '{"query":"Cheddar cheese", "pageSize": 25}' https://api.nal.usda.gov/fdc/v1/foods/search?api_key=someAPIkey
however, including a "dataType":"Foundation" filter gives this error: status":400,"error":"Bad Request","message":"Invalid request parameter or body"
example: curl -H "Content-Type:application/json" -d '{"query":"Cheddar cheese", "dataType":"Foundation", "pageSize": 25}' https://api.nal.usda.gov/fdc/v1/foods/search?api_key=someAPIkey