I keep getting the error 'SCRIPT1004: SCRIPT1004: Expected ';'' on the returned result.
Here is my code:
$.ajax({
type: "POST",
url: "">npiregistry.cms.hhs.gov/.../ + NPI + "",
dataType: "jsonp",
jsonpCallback: 'processJSONPResponse', // add this property
contentType: "application/json; charset=utf-8",
success: function(data) {
console.log(data);
},
error: function(data){
console.log(data);
}
});
I tried changing the method to GET and Changed the data type to JSON then it would throw CORS issue. Please suggest. Thanks.
Thank you.
Hi Karthik,
Because the website "https://npiregistry.cms.hhs.gov/" has blocked CORS request, so you need a intermediate server to help you handle request,
which means it will send request to hhs.gov, then the server will forward result to you. (like a Proxy)
There are some serverless solutions to meet your requirement.
1. Free public CORS forward service:
https://cors-anywhere.herokuapp.com/
https://github.com/netnr/workers( https://cors.zme.ink/ * )
Usage:
url: serverUrl/apiEndpoint
Here is my demo, run the request by clicking a button.
$.ajax({ type: 'GET', url: "https://cors-anywhere.herokuapp.com/https://npiregistry.cms.hhs.gov/api/?version=2.0&number=1316459605", // url: "https://cors.zme.ink/https://npiregistry.cms.hhs.gov/api/?version=2.0&number=1316459605", // only required when using the first url beforeSend: function(request) { request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); }, success: function (data) { console.log(data.results[0]); }, error: function (data) { alert('failed'); } });
result:
2. Create your own proxy server with Cloudflare Worker service, the second service(*) is built on it.
https://workers.cloudflare.com/
demo project:
https://github.com/Zibri/cloudflare-cors-anywhere
Regards,
Clofly
this is on portal field on change event.
I do get CORS issue when I use the dataType json hence I switched it to jsonp. I'm trying this on a custom portal field on change event. The funny thing is my block of code executes but enters error with the status code 200.
Here is my code:
function getNPPESData() {
var NPI = $('#nact_npi').val();
if (NPI != null) {
$.ajax({
type: 'GET',
url: "npiregistry.cms.hhs.gov/.../ + NPI + "",
dataType: 'jsonp',
success: function(data) {
alert('success');
},
error: function(data){
alert('failed');
}
});
}
}
The error on console when I debug:
SCRIPT1004: SCRIPT1004: Expected ';'
api (1,16)
Here is my api response:
{"result_count":1, "results":[{"enumeration_type": "NPI-1", "number": 1316459605, "last_updated_epoch": 1508976000, "created_epoch": 1508976000, "basic": {"first_name": "BIANCA", "last_name": "AARON", "credential": "MFTI, PCCI", "sole_proprietor": "NO", "gender": "F", "enumeration_date": "2017-10-26", "last_updated": "2017-10-26", "status": "A", "name": "AARON BIANCA"}, "other_names": [], "addresses": [{"country_code": "US", "country_name": "United States", "address_purpose": "LOCATION", "address_type": "DOM", "address_1": "1540 E COLORADO ST", "address_2": "", "city": "GLENDALE", "state": "CA", "postal_code": "912051514", "telephone_number": "818-244-7257", "fax_number": "818-243-5431"}, {"country_code": "US", "country_name": "United States", "address_purpose": "MAILING", "address_type": "DOM", "address_1": "4760 SEPULVEDA BLVD", "address_2": "", "city": "CULVER CITY", "state": "CA", "postal_code": "902304820", "telephone_number": "310-390-6612", "fax_number": "310-398-5690"}], "taxonomies": [{"code": "106H00000X", "desc": "Marriage & Family Therapist", "primary": true, "state": "", "license": ""}], "identifiers": []}]}
Hi Karthik,
Could you share how would you like to integrate data from https://npiregistry.cms.hhs.gov/ within your Dynamics 365 environment?
E.g: display them in web resource or a web page of Portal?
The error told us that npiregistry has blocked XMLHttpRequest request from other websites/domains except itself.
Please find whether there is setting in npiregistry to allow your website or domain to access its data.
If you can't find such setting, it means that we couldn't get data from front-end, thus you need to get data with back-end method.
You could use HTTP connector to request API(back-end way) and read its JSON body with other connectors without building a web application.
e.g: Get Baltimore data from npiregistry.
Regards,
Clofly
is this related to portals or crm?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156