Copy and Paste Requests and CURL Commands
You can easily copy and paste HTTP requests in a variety of formats by using the Copy and Paste commands in the request editor.
Copy Format
- WebSurge Http Request Trace (plain text)
Paste Formats
- WebSurge Requests
- CURL Commands
- Visual Studio HTTP Requests (single request)
Copy Operation
The Copy operation lets you copy the current WebSurge request and turns it into a request trace string. It's a plain text string of an Http Trace that is similar to what you see in the Preview editor.
WebSurge Request Format: Plain Http Traces
WebSurge's request format is raw Http Traces with a separator between requests. The request format is plain text and you can 'manually' copy a trace from a Session file and paste it as an individual WebSurge request. Many other tools also output raw Http traces so you can capture output from those as well and paste individual requests in the same way.
Http Traces can be request-only or request and response depending what is currently active in the Request Previewer.
To copy just the request when a response is also visible, navigate to a different request, then navigate back to the request you want to copy to clear the response and leave only the request in the previewer.
An example of a request only trace:
POST https://albumviewer.west-wind.com/api/posttrack HTTP/2.0
Accept-Encoding: gzip,deflate
Accept: application/json
Authorization: Bearer eyJhbGciOiJIU",
User-Agent: West Wind HTTP .NET Client
Content-Type: application/json
{
"Id": 1,
"SongName": "End of the Silence",
"ArtistId": 10
}
or a request and response result:
GET https://albumviewer.west-wind.com/api/artistlookup?search=S HTTP/2.0
Accept-Encoding: gzip,deflate
HTTP/1.1 200 OK
Content-Length: 147
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/10.0
Date: Sat, 02 Sep 2023 01:01:41 GMT
[
{
"name": "Scorpions",
"id": "Scorpions"
},
{
"name": "Skindred",
"id": "Skindred"
},
{
"name": "Saxon",
"id": "Saxon"
},
{
"name": "Soundgarden",
"id": "Soundgarden"
}
]
This text is copied to the clipboard and you can use it as you wish for documentation or for using it with some other tool.
You can also Paste this request into a new or other existing request and overwrite the existing request's content. It's a quick way to copy request content to another request, a new request, or even a new or updated request in another separate WebSurge Session.
Paste Operations
Paste operations come in various flavors and they are auto-detected based on the content that is on your clipboard.
Paste WebSurge Request
If you previously copied a WebSurge request to the clipboard either using the Copy Operation described above or by some other mechanism you can paste that request into a new or different request .
Pasting overwrites whatever content is there originally and replaces it with the new content.
Paste CURL Commands
CURL is a popular tool for running HTTP commands and CURL syntax is often used for documentation of APIs. So it's quite useful to turn CURL commands directly into requests in WebSurge.
You can do this by:
- Copy a CURL command to your clipboard
- Create a new Request in WebSurge (ctrl-n)
- Or: You can overwrite an existing request with the paste operation
- Find Paste Button in the Request Editor (right hand button set)
- Click the Paste button to update the current request
Paste Visual Studio Http File Content
Visual Studio 2022 introduced .http
files to run REST requests right out of the VS Editor and you can import individual requests by copying them from Visual Studio and pasting them into an individual request in WebSurge.
Note: You can also Import and Export Visual Studio
.http
files using the File Open and Save operations as well as from the File -> Session -> Import and Export menu.
© West Wind Technologies, 2014-2023 • Updated: 09/01/23
Comment or report problem with topic