Fiddler – request redirection

As a back-end developer I am quite often contacted by front-end devs to take a look why certain UI calls to the server results in wrong data being returned by API. Usually I am provided with request payload so it is quite straightforward to reply it with Postman or Fiddler and see what is going on the backend. However for time to time, replying single request is not enough to reproduce the problem. In that case it is easier to just recreate the scenario on the UI and debug the API during that process. Unfortunately this approach requires backend devs to have UI up and running on their local machines and that is not always possible (e.g. you might not get access to UI repository). Fortunately with Fiddler it is quite easy to intercept outgoing front-end calls to the API and redirect them to your locally deployed version (so you can easily debug the API).
Let’s assume we would like to redirect all simpletestspa.azurewebsites.net calls to localhost:50277. In order to do that run Fiddler and go to Tools -> Hosts…
Fiddler - tools
Select “Enable remapping of requests for one host to a different host or IP, overriding DNS” checkbox
Fiddler - hosts window
and enter following values in the editor

From now every outgoing request to simpletestspa.azurewebsites.net will be redirected to your local instance of the server on localhost:50277.

Fiddler – request redirection

Cake – Data at the root level is invalid

Couple of weeks ago I mentioned that in my current project we use Cake as a build mechanism. Recently we wanted to add simple functionality to our build script, which would allow us to modify one of the App.config‘s properties. According to the documentation it should be a straightforward tasks, as all the heavy lifting can be done via XmlPeek and XmlPoke aliases.
Our initial script looked as follows

And what was surprising for us, it didn’t work.
dataattherootlevel
We got a bit weird error “Data at the root level is invalid. Line 1, position 1”. The exception suggested that there was something wrong with our App.config file. However if you look at the picture presented above, you will see that we were able to successfully read the file and retrieve value of Version with XmlPeek method. After a bit of digging it turned out that XmlPoke and XmlPokeString are not able to work with relative paths and we have to use absolute one in order to make it work. Fortunately there is an easy way to do that, namely MakeAbsolute method. Out script after modifications looks that way

And now everything works fine
after

Source code for this post can be found here

Cake – Data at the root level is invalid