Rewrite – Modify the Request

The Rewrite feature allows you to automatically modify different elements of a Request. If you are familiar with Breakpoints, you can think of Rewrites as ‘automated Breakpoints’.

The Rewrite feature has a long list of other rules you can add to your Request. You can add rules to:

  • add, edit or delete headers
  • change the URL or path
  • change a parameter/query string

This tutorial will show you how to use the Rewrite feature to automatically add a header each time a Request is made to a specific URL.

Prerequisites

Go to the OpenBank API Products’ endpoint

Open Chrome and go to NAB’s Products endpoint

You should now get an error about about a “Missing mandatory header” (the missing header is called ‘x-v’)

Enable SSL Proxying

In Charles, right click the OpenBank request and click the “Enable SSL Proxying” option

The Request(s) you want to modify must be decrypted before you can use the Rewrite feature with it

Reload the page on Chrome

Return to Charles where you should now get a 406 error. Request details should be displayed in plain text

Copy URL

Right click the Request and click the “Copy URL” option

Open Rewrite screen

Tools -> Rewrite -> tick the “Enable Rewrite” checkbox

Setup Rewrite – Location

Add -> Click Add (from the ‘Location’ section) -> Paste URL (copied from a previous step above) into “Host” field -> press the “tab” on your keyboard (this will auto populate most of the fields) -> set the “Port” to 443

This is a good article which explains what port 443 is all about

Setup Rewrite – Rule

Click Add (from the ‘Rule’ section) -> select “Add Header” from the “Type” dropdown -> in the “New” section add the following details:

  • Name: x-v
  • Value: 1

Finally, click the ‘OK’ button to save the Rule

Reload the page in Chrome

You should now see a list of Products

From now on Charles has will now automatically add the ‘x-v’ header every time you go to NAB’s Products endpoint

Details of Rewrite

If you return to Charles, you should see a 200 status code and a list of Products in the Response body.

If you click on ‘Overview’ you should see a section called ‘Notes’ which will list all Rewrite rules that have been applied to this Request

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: