abrahamgarcia27 Posted May 22, 2014 Share Posted May 22, 2014 I am having an error doing an ajax call to this REST point this is the point http://api.ingrub.com/v2/locations/32.6724822/-116.9447485 this is the ajax function with jquery $.ajax({ url: 'http://api.ingrub.com/v2/locations/32.6724822/-116.9447485', type: "GET", beforeSend: function(xhr){xhr.setRequestHeader('auth', 'b26d5f5881f8a030e2d33085a65ad15e');}, dataType: 'json', success: function(response) { } }); I get a 404 error Not Found. Any ideas why this might be happening? Quote Link to comment https://forums.phpfreaks.com/topic/288665-api-error/ Share on other sites More sharing options...
trq Posted May 22, 2014 Share Posted May 22, 2014 Works as expected in Postman. https://www.dropbox.com/s/obmu6zdl7xx4nfj/Screen%20Shot%202014-05-22%20at%201.25.36%20pm.png Quote Link to comment https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480393 Share on other sites More sharing options...
abrahamgarcia27 Posted May 22, 2014 Author Share Posted May 22, 2014 But its not working with the jquery code Quote Link to comment https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480399 Share on other sites More sharing options...
trq Posted May 22, 2014 Share Posted May 22, 2014 I would suggest you contact the provider, something weird is going on there. Quote Link to comment https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480401 Share on other sites More sharing options...
abrahamgarcia27 Posted May 22, 2014 Author Share Posted May 22, 2014 I wrote The api myself or you mean the hosting company? Yeah it is really weird i still cannot understand it Quote Link to comment https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480403 Share on other sites More sharing options...
trq Posted May 22, 2014 Share Posted May 22, 2014 I meant the api provider. If you don't know what it is, i'm not sure who would. What do the logs say about these requests? Quote Link to comment https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480411 Share on other sites More sharing options...
abrahamgarcia27 Posted May 22, 2014 Author Share Posted May 22, 2014 I am not getting any error log this are the latest one /home/ingrub/public_html/api/v2/index.php on line 53 [05-May-2014 04:31:16 UTC] PHP Fatal error: Call to a member function get() on a non-object in /home/ingrub/public_html/api/v2/index.php on line 53 [05-May-2014 04:32:13 UTC] PHP Fatal error: Call to a member function post() on a non-object in /home/ingrub/public_html/api/v2/index.php on line 53 [05-May-2014 05:39:50 UTC] PHP Parse error: syntax error, unexpected T_VARIABLE in /home/ingrub/public_html/api/v2/index.php on line 67 its weird because when i use it in my rest application to call the info it works fine, but not via ajax so i have a feeling something is wrong with the jquery function this is the console log error from the browser Failed to load resource: the server responded with a status of 404 (Not Found) http://api.ingrub.com/v2/locations/32.6724822/-116.9447485 XMLHttpRequest cannot load http://api.ingrub.com/v2/locations/32.6724822/-116.9447485. Invalid HTTP status code 404 index.html:1 Quote Link to comment https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480454 Share on other sites More sharing options...
kicken Posted May 22, 2014 Share Posted May 22, 2014 Is the 404 being generated by the webserver, or by your API? If it's generated by the webserver you should check the server's error log for information about why. If it's generated by the API you'll need to debug the api code to figure out why. Quote Link to comment https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480456 Share on other sites More sharing options...
abrahamgarcia27 Posted May 22, 2014 Author Share Posted May 22, 2014 When i was developing the API i had problems with the apache_request_headers so i added the following function to fix the issue if( !function_exists('apache_request_headers') ) { function apache_request_headers() { $arh = array(); $rx_http = '/\AHTTP_/'; foreach($_SERVER as $key => $val) { if( preg_match($rx_http, $key) ) { $arh_key = preg_replace($rx_http, '', $key); $rx_matches = array(); // do some nasty string manipulations to restore the original letter case // this should work in most cases $rx_matches = explode('_', $arh_key); if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) { foreach($rx_matches as $ak_key => $ak_val) { $rx_matches[$ak_key] = ucfirst($ak_val); } $arh_key = implode('-', $rx_matches); } $arh[$arh_key] = $val; } } return( $arh ); } } I believe this is the problem. i am going to try to change environment see if i get a different result Quote Link to comment https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480535 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.