Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  1] [ 1]  / answers: 1 / hits: 42864  / 9 Years ago, wed, april 8, 2015, 12:00:00

I'm trying to use the BloomAPI to retrieve Doctor's NPI number by querying with their first and last name. I'm using Jquery Ajax to make a get request for the JSON data.



I am able to get the JSON data when I do CURL in the terminal: curl -X GET 'http://www.bloomapi.com/api/search?offset=0&key1=last_name&op1=eq&value1=LIN&key2=first_name&op2=eq&value2=JOHN'



For the purpose below - I just hardcoded in the params into the URL.
I get a Failed to load resource: the server responded with a status of 400 (Bad Request Error. Any idea what I might be doing wrong?



$.ajax({
type: 'GET',
url: 'http://www.bloomapi.com/api/search?offset=0&key1=last_name&op1=eq&value1=LIN&key2=first_name&op2=eq&value2=JOHN',
dataType: 'jsonp'
}).done(function(server_data) {
console.log(server_data)
}).fail(console.log(failed));

More From » jquery

 Answers
8

This was a weird one... your code is actually basically correct, however, it appears bloomapi does not support disabling caching in the way jquery does it.



When you make the jquery call you have, the actual url becomes something like this:



http://www.bloomapi.com/api/search?offset=0&key1=last_name&op1=eq&value1=LIN&key2=first_name&op2=eq&value2=JOHN&callback=jQuery111207365460020955652_1428455335256&_=1428455335257


The callback is a jsonp construct, and the _ is a way of breaking caching. However, bloomapi appears to not like this:



jQuery111207365460020955652_1428455335256({name:ParameterError,message:_ are unknown parameters,parameters:{_:is an unknown parameter}});


To get around this, you can disable cache busting like so:



$.ajax({
type: 'GET',
url: 'http://www.bloomapi.com/api/search?offset=0&key1=last_name&op1=eq&value1=LIN&key2=first_name&op2=eq&value2=JOHN',
dataType: 'jsonp',
cache: true
}).done(function(server_data) {
console.log(server_data)
}).fail(function() { console.log(failed) });


You will have to be careful of how else you break the cache if that's an issue; the api provider may be able to provide feedback on how to do this.



In the future, you can easily check the errors you are receiving/what you are sending using a web debugger; I used Fiddler to figure this out.


[#67159] Monday, April 6, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
darennevina

Total Points: 422
Total Questions: 128
Total Answers: 105

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
;