1

http://crmqa.org/sites/crmqa.org/modules/civicrm/extern/rest.php?json=1&entity=pax&action=fetchAddressDetails&api_key=apikeyofcontact&key=sitekey

When I call this through ajax and check in console I see 302 found and response is the login page of my application. In some other cases the api works fine it gives the required response when it is passed as form data.
Eg: Doesn't work

$.ajax({
           url: weblink,
           dataType: "json",
           method: "POST",
           contentType: "application/json; charset=utf-8",
           data: '{"pincode" : "' + pincode + '"}',
           success: function(data) {                    
               if (data.length > 0) {                        
               } else {                            
               }
           }});

but this: Works

$.ajax({
            url: weblink,
            dataType: "json", 
            method: "POST",
            data: { "event_id": event_id },
            success: function(data) {
                $('.loading').remove();
                $('.event_id').val(event_id);
                //my code
            }});

Please help.

1

finally I got the issue. It was related to the api URL. In ubuntu we created a link folder so the url worked. In windows the symbolic link was not created and also doesn't work so based on htaccess since the api was not found at the location it was redirecting to login page . Small thing but took hours to nail it down . Thanks anyways :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.