Search code examples
jqueryjsonfiddlerauto-responder

Fiddler AutoResponder should returns a json response with jQuery session id given in request


I need your help, I develop a javascript code that ask a webservice and get back data in JSON format.

When I ask the webservice like this :

https://Server/ServiceEndPoint?id=12345

MyApplication adds some other parameters to my web service URL like this :

https://Server/ServiceEndPoint?id=12345&callback=jQuery18205735686348496944_1459416484049&_=1459416484892

This jQuery session id is generic.

So, I'm using Fiddler to simulate the webservice response. And I need to add this jQuery session Id in the begining of my response like this :

jQuery18205735686348496944_1459416484049({"data":"JSON data"})

Can any one helps me to do this.

Thank you.


Solution

  • I Used FiddlerScript to do it :

        if (oSession.HostnameIs("ServerName")){
    
            var body = "";
            var s_qs = (oSession.url + "?").split("?")[1];
    
            var querystring = HttpUtility.ParseQueryString(s_qs);
            var s_callback = querystring.Get("callback");
    
            if(oSession.uriContains("EndPointName"))
            {
                body = s_callback + "({'data':'datContent'})";
            }
            oSession.utilSetResponseBody(body);
        }