-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the NSF award API endpoint #2233
Comments
Thanks for the report, @jeanetteclark. The reason that we used the proxy in the first place was to bypass Same Origin restrictions on 3rd party API access. I'm not sure what changed there, maybe we fixed it through CORS headers? In any case, @robyngit and @rushirajnenuji, this is a problem that needs to get fixed ASAP, as it is hitting the datateam members. Could one of you look into it -- hopefully it will be a minor issue. Thanks. |
FYI I switched the apache config back. The award lookup is still not working in metacatUI even with the old config. I also checked with the current datateam and they say the UI lookup has not worked for a while now. |
Notes:
|
Another report of problems with the award lookup from RT today:
|
Updating the ADC config to use the new endpoint for the The The search term "arctica" should return results. Here is an example query that works in the browser: https://www.research.gov/awardapi-service/v1/awards.json?keyword=arctica&printFields=title,id&callback=jQuery191024293065478125508_1704926101036&_=1704926101037 |
Looking further into this, the request to the awards API is failing because of a CORS issue: the response is blocked by the same-origin policy. It appears that we were previously getting around this by requesting the API to return JSONP (JSONP is not subject to the same-origin policy). Although "callback" is still a valid parameter accepted by the API, it looks like the response is no longer being wrapped in a callback function. I tested this both in the browser and with curl, and the response is plain JSON, not JSONP. I also tried the same request with the old endpoint, and using the "jsonp" parameter instead of "callback"; neither returned JSONP. The only documentation that I can find for this API appears to be out of date since it's still referencing the old endpoint. I'm not sure if there's any documentation for the new endpoint, but it would be helpful to know if JSONP is still supported. Possible solutions:
Update: we do in fact already have a proxy set up for this API, it's just not working as expected, investigating this now... |
After much slack discussion, we've got the problem narrowed down: Historically MetacatUI was using JSONP to get around NSF's lack of CORS support. NSF did a rewrite of their API (hence the change in the endpoint URL) and it seems that they dropped support for JSONP at the same time. Given the lack of support for CORS and JSONP, MetacatUI will need to make requests via a server-side proxy. The Apache setup for the ADC was already configured to proxy requests to the NSF award API, however, the proxy needed to be updated to the correct URL (including www and using https instead of http). This has now been corrected, so we can now update MetacatUI to make requests to the proxy and to request and handle JSON responses rather than JSONP. For the ADC, the Any repository that wants to use the NSF award lookup feature will need to set up their own proxy. We could configure the default To Do:
|
- Update the default grantsUrl to point to a proxy relative to the repository’s domain - Remove unused getGrant method from the LookupModel - Use native fetch API instead of jQuery.ajax to retrieve grants - Show spinner to indicate that grants are being retrieved (was set up but not used) - Move some logic from the getGrantAutocomplete method to new, smaller methods - Add missing JS docs - Add error handling Issue #2233
- Update the default grantsUrl to point to a proxy relative to the repository’s domain - Remove unused getGrant method from the LookupModel - Use native fetch API instead of jQuery.ajax to retrieve grants - Show spinner to indicate that grants are being retrieved (was set up but not used) - Move some logic from the getGrantAutocomplete method to new, smaller methods - Add missing JS docs - Add error handling Issue NCEAS#2233
Describe the bug
Currently, for the NSF award lookup on the ADC, metacatUI looks at https://api.nsf.gov/services/v1/awards.json. This endpoint has a redirect that doesn't work so well and was causing failing award lookups in metadig engine. I changed the proxy in our apache config to research.gov/awardapi-service/v1/awards.json. I think that at a minimum the metacatUI lookup should move to that endpoint, and probably it should be using the proxy instead. @mbjones indicated that this might be overridden in a config somewhere so possibly a non issue, but the award lookup doesn't seem to be working for me right now.
The text was updated successfully, but these errors were encountered: