Fiddler Classic: how to implement a rule that will change the payload of the request before sending it to the server? - fiddler

Using Fiddler Classic I can use AutoResponder to create a rule that will intercept a request and will return a custom response without sending the request to the server. Having multiple such rules I can export them and import them back.
Is it possible to create a rule that will change the payload of the PUT/POST and then send the modified request to the server? This is useful if I want to send a request that the UI validation will not allow it to be sent.
If yes, where do I create these rules? In AutoResponder? If not in AutoResponder, can they be exported/imported?

Related

Is Fiddler AutoResponder compatible with SOAP apis?

When I drag an existing call to Autoresponder it generates a rule based on the method and URL. This works fine for REST APIs but not for APIs that are not based on the URL(like SOAP). Is there a way to make it respond based on the request body?
I'll explain the full use case. I have a .saz containing about 100 POST request to a SOAP API containing a repro for a bug in a application that I've created. I'm looking for an easy way to replay the communication that causes my app to crash.
You can use fiddler to respond with soap but because the URLs are the same for different calls, only one can be set up to respond at a time. After generating the rule create a .dat file that contains the soap response.

How to send POST request without using form

I want to pass a parameter to a method using POST request. Since all data is generated after some logic, I don't want to use form to send such request. Is is possible in playframework?
you can use play ws. It allows you to do HTTP requests

What's the REST way to verify an email?

When a user register to my web application I send an email to verify his inbox.
In the email there are a link to a resource like this:
GET /verify/{token}
Since the resource is being updated behind the scenes, doesn't it break the RESTful approach?
How can I do it in a RESTful manner?
What you are talking about is not REST. REST is for machine to machine communication and not for human to machine communication. You can develop a 1st party REST client, which sends the activation to the REST service.
You can use your verification URI in the browser to access the REST client:
# user follows a hyperlink in the browser manually
GET example.com/client/v1/verify/{token}
# asking the client to verify the token
and after that the REST client will get the hyperlink for verification from the REST service and send the POST to the service in the background.
# the REST client follows the hyperlinks given by the service automatically
# the REST client can run either on the HTTP client or server side
GET example.com/api/v1
# getting the starting page of the REST service
# getting the hyperlink for verification
POST example.com/api/v1/verification {token}
# following the verification hyperlink
If you have a server side 1st party REST client, then the HTTP requests to the REST service will run completely on the server and you won't see anything about it in the browser. If you have a client side REST client, then you can send the POST in the browser with AJAX CORS or you can try to POST directly with a HTML form (not recommended). Anyways the activation should be a POST or a PUT.
It depends on what are you trying to do.
Does it fire an email after validating the user for example? If so, it is not an idempotent method and you should use POST.
Example:
POST /users/{id}/verify/{token}
If the method doesn't have any consequence besides the update, I think you should use PUT.
Aren't you overthinking REST? With e-mail verification you want the user to be able to simply click the link from whatever mail user agent he is using, so you'll end up with a simple GET on the server (presented as a hyperlink to the user) with the token either in the path or as part of the query string:
GET http://example.com/verify-email/TOKEN
GET http://example.com/verify-email?token=TOKEN
Either is fine for this use case. It is not really a resource you are getting or creating; just a trigger for some process on the backend.
Why do you think this would run afoul of good design?

Asp.Net Web API content negotiation

…API/emailMessage/?emailId=test123
I have written the above URL using Web API to get the email in JSON data format(email body, sender, CC, To, etc).
Also, I have the requirement to allow download of email along with attachment for the same URL.
One way to do it is using content negotiation. I can use “MediaTypeHeaderValue("application/octet-stream")” to send the content as downloadable.
Question is….
1. Which parameter in the GET request the user should request for JSON content or download of content? Or what is the correct way of asking the content type from HTTP client?
2. On the server side I can read what content type the user is asking and send the appropriate data just using case statement. Is there anything to be considered on the server side in this scenarios?
Thank you,
Eric
The Accept request header is used to inform the server what media types the client supports. However, do not be concerned about adding a format= parameter to your URI to request a different format. It will not have a negative impact on your application.

REST client - How to send data with PUT request?

I've created a REST API using Codeigniter and I'm testing it with wiztools.org REST client https://code.google.com/p/rest-client/
How can and should I send data for a PUT request? I've seen some PHP examples where JSON is sent in the headers but I'm not sure how to do this in the client I'm testing with or how to read this data from the request.
You can use cURL to send PUT requests.