DEV Community

Cover image for Copy HTTP Requests from Chrome/Edge DevTools to PowerShell/cURL/Fetch
Niels Swimburger.NET πŸ”
Niels Swimburger.NET πŸ”

Posted on β€’ Originally published at swimburger.net on

5

Copy HTTP Requests from Chrome/Edge DevTools to PowerShell/cURL/Fetch

As we develop websites, apps, and services, we make many HTTP requests from the browser to the server. During debugging sessions, replaying HTTP requests can take a lot of manual effort. For example, filling out multiple forms to ultimately hit that submit-button or going through a long wizard.

Google Chrome and Microsoft Edge DevTools can speed up your inner loop by copying recorded HTTP requests as PowerShell, cURL, or Fetch. Follow these steps to copy HTTP requests as PowerShell:

  1. Open DevTools in Chrome or Edge by pressing 'F12' or using the options menu > More Tools > Developer Tools. Switch to the Network tab. Screenshot of how to open DevTool on Microsoft Edge browser. Using the options menu > More Tools > Developer Tools
  2. Manually go through your application so the DevTools will record your HTTP requests.

Enable "Preserve Log" if necessary. Preserve Log will make sure your HTTP requests don't get wiped when the pages refreshed. This is very useful when you want to debug HTTP request while going through full page refreshes.

Screenshot of Edge DevTools recording HTTP Requests in the Network tab

  1. Right-click the desired HTTP request and click on Copy > Copy as PowerShell Screenshot of how to Copy HTTP Requests as PowerShell in Edge DevTools
  2. Open a PowerShell window and paste the contents from your clipboard and hit enter. For PowerShell, you can copy from clipboard by right-clicking the shell window. Screenshot of PowerShell script execution of the HTTP Request in a PowerShell window

You can copy multiple HTTP Requests in case your HTTP Requests depend on each other. Save these commands as a PowerShell script file (.ps1) if you want to reuse it in the future.

Now you can very quickly make your HTTP Requests by running a single command without manually interacting with the browser. I hope this will save you time and keystrokes when debugging server requests!

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (1)

Collapse
 
reece_roberts_9e2e3dc0549 profile image
Reece Roberts β€’

how do i do this on mac, i dont have the copy as powershell option

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay