• mmahm
  • NEWBIE
  • 5 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi,

 

I need to implement a REST service that returns data in JSONP format (JSONP format required for cross-domain ajax calls). I'm calling this service by jQuery ajax. But it always raises error : Error jQuery17109439062654184185_1342893046903 was not called.

The reason is that REST API only supports JSON and XML. In this case JSONP always returned as a XML. I'm wondering is there any workaround for this?

 

Here is my apex code:

 

@RestResource(urlMapping='/BookingService/*')
global class noqBookingService {

global class BookingStatus {
    global String ReferenceId { get; set; }
    global integer Threshold { get; set; }
}

@HttpGet
    global static String getQueueStatus() {
        String referenceId = req.params.get('referenceId');
        String jsonp_callback = req.params.get('callback');
        
        BookingStatus status = new BookingStatus();
        status.ReferenceId = referenceId;
        status.Threshold = 8;
        System.debug(jsonp_callback+'(['+JSON.serialize(status)+'])');
        
        return jsonp_callback+'(['+JSON.serialize(status)+'])';        
    }    
}

 Visualforce code:

 

$(document).ready(function() {
        $.ajax({
            url:'https://My-Site-Domain/services/apexrest/BookingService?callback=?',
            type:'GET',
            dataType: 'jsonp',
            contentType: 'application/javascript',
            success: function(status){ alert('success');},
            error:function(xhr, ajaxOptions, thrownError){ alert('error:'+thrownError);}
        });
    });

 

  • July 21, 2012
  • Like
  • 0

 

Hi.

 

I created an  Authenticated Website User License.

While creating  this User License I found in the profile that only 

Standard Object Permissions is to "Document" only.

There was no permission to other Standard Object like Contact,Account.

 

To test this I created a VF page called 'My Page' which inserts a record to the Contact.

The user after login 'My Page' is displayed and when the button in the 'My Page' is clicked

a new Contact record is created.

 

I am very much surprised that in profile there is no permission for Contact,

but Authenticated Website User was able to create a new record in the Contact....!

 

 

Cheers

suresh