create-and-fetch-resource.http
@baseUrl = https://api.example.com
@resourceId = replace-with-id-from-create-response
### Create a resource
POST {{baseUrl}}/widgets
Accept: application/json
Content-Type: application/json
{
"name": "Sample widget"
}
### Fetch it after manually copying the returned ID into resourceId
GET {{baseUrl}}/widgets/{{resourceId}}
Accept: application/json
Variables to replace
- baseUrl
- The API origin.
- resourceId
- The ID copied from the create response before running the GET request.
Expected response
Create commonly returns 201 Created with the resource ID in JSON or a Location header. Copy that ID into resourceId; the second request should then return 200 OK.
Karve does not perform response chaining, so it will not populate resourceId from the POST response automatically.
Related examples and guides
Learn the full syntax in the .http file format guide, manage secrets with variables and environments, or see how to run .http files on Windows.
Run this request without leaving Windows.
Karve opens .http files as a native workspace: edit the plain text, press Run, inspect the response, and keep the file in Git.
15-day free trial · No account · No subscription · No metered requests
25% off until Sep 1