How to change a request body automatically according to the previous response?

22 posts, 0 answers
  1. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 10 Jun 2014 Link to this post

    First ,I want to say that fiddler is a reallllllly useful tool !

    However, I have been disturbed for a long time about this problem. So here is the problem.

     
    Step 1.

    I received a response from server like this   (some useless headers have been omitted) :
     

    HTTP/1.1 200 OK
    Server: GewaServer3
    Content-Type: text/html;charset=UTF-8
    Content-Length: 48

    var data = {"retval":"145918761","success":true}

     

    Step 2.

    After receiving the previous response, I hope fiddler could automatically send the request like this:
     

    POST http://www.gewa.com/ajax/trade/save.xhtml HTTP/1.1
    Host: www.gewa.com
    Connection: keep-alive
    Cookie: bdshare_firstime=1385011581672;
     
    code=1321&Id=145918761&type=1556
     


    But  I hope this part in request body 

    (Id=145918761)

    will be automatically changed according to the response body I received before 

    ("retval":"145918761")

     
    I try to find a way to solve the problem for many days but I couldn’t.

    If anyone could help I would be soooooo grateful!

    Thanks again!
     

     

     

     
  2. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 10 Jun 2014 Link to this post

    Hello, Danny--

    When you say "you hope Fiddler could automatically send the request"-- do you mean that Fiddler would create a new request, or that Fiddler would change a subsequent request that was sent by the client software?

    You can see some examples of how to send requests automatically from script:
    https://groups.google.com/forum/#!searchin/httpfiddler/utilissuerequest/httpfiddler/8T4ZOsOm20E/W5A_d-NEJDYJ

    and here:

    https://groups.google.com/forum/#!searchin/httpfiddler/utilissuerequest/httpfiddler/CyXSDkug_es/V3zBA0OeNjcJ


    Regards,
    Eric Lawrence
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 in reply to Eric Lawrence Link to this post

    Hi Eric Lawrence

    Thanks for your reply.

    By saying that, I mean that Fiddler would create a new request.
     
    So here is the whole progress:

    1.    
    When fiddler receive a response from www.gewa.com and the body contain ["success":true],
    then copy the number after [terval].  (which is 145918761 in my first post)

    2.    
    Fiddler create a new request(like the request in my first post). But I hope fiddler could replace the number in request body 
    after [id=]

    3.    Send the new request.

    Sorry for bothering you again.  Thank you!







  4. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello Eric,

    I have made some progress.

    Here is the script i wrote:

    if (oSession.HostnameIs("www.gewa.com")){ 
                oSession.utilDecodeResponse();
                 if (oSession.utilFindInResponse("false", true) > -1){ 
                 var oBody = oSession.GetResponseBodyAsString (); 
                   var a = 'var data = {"retval":"'
                   var b = '","success":true}'
                    oBody = oBody.replace(a, "");
                    oBody = oBody.replace(b, "")  
                    FiddlerObject.utilIssueRequest(s);
                    } 
     } 
    Now I meet a new problem, which is "how to create a new request"

    Having read some docs, i found this two may be useful
    1.  FiddlerObject.utilIssueRequest(s);
    2.  FiddlerApplication.oPorxy.InjectCustomRequest

    However, the first could be used only when a client create a request before.
    So the second may be helpful.  But i don't know how to use it. Could you show me how to do that ?

    Another thing is , I hope the new request that fiddler created would be sent 20 times.  But i want to add some delay between each time. 
    Can we do this in fiddler script?

    Thank you again for helping me.

    Have a nice day!

               



  5. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  6. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  7. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  8. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  9. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  10. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  11. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  12. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  13. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  14. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  15. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  16. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  17. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  18. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  19. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  20. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    Hello again,

    I just find this :

    FiddlerApplication.oProxy.SendRequest(oSession.oRequest.headers, oSession.requestBodyBytes, null);

    May be this will be pretty helpful for me.

    The requests that every time i want fiddler create is almost the same except for the number after "id=".

    Could you show me how to write this part?

    Thanks a lot.




  21. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 11 Jun 2014 Link to this post

    Hi, Danny--

    Unfortunately, your question is too vague for me to be of much help. You can modify the request body by editing the requestBodyBytes array.

    Regards,
    Eric Lawrence
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  22. Danny
    Danny avatar
    22 posts
    Member since:
    Jun 2014

    Posted 12 Jun 2014 Link to this post

    Hello Eric,

    Thanks again for your help.

    Have a nice day
Back to Top