This is a migrated thread and some comments may be shown as answers.

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

21 Answers 1502 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Danny asked on 10 Jun 2014, 01:49 PM
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!
 

 

 

 

21 Answers, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 10 Jun 2014, 03:10 PM
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.

 
0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 01:19 PM
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!







0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 04:48 PM
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!

           



0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:04 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Danny
Top achievements
Rank 1
answered on 11 Jun 2014, 05:05 PM
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.




0
Eric Lawrence
Telerik team
answered on 11 Jun 2014, 10:07 PM
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.

 
0
Danny
Top achievements
Rank 1
answered on 12 Jun 2014, 12:02 PM
Hello Eric,

Thanks again for your help.

Have a nice day
Tags
Fiddler Classic
Asked by
Danny
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
Danny
Top achievements
Rank 1
Share this question
or