Jump to content

API Error


Recommended Posts

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? 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.