Responses and Cookies
After you click Send, DocStar shows the response below the request. Use it to check that the API behaves as expected, debug errors, and save good responses into your docs.
Read the response
The panel has two tabs: Response (the live result) and Sample Response (the examples saved for your docs).
At the top of Response you see:
- Status: the HTTP status code and text, such as
200 OKor404 Not Found. Success codes show in green, errors in red. - Time: how long the request took.
- A copy icon that copies the response body.
Below that are four tabs:
| Tab | What it shows |
|---|---|
| Body | The response body. Pretty formats JSON, Raw shows the exact text, and Preview renders HTML. |
| Headers | Every response header as a key and value. |
| Test Results | Tests from your Post-Script, with a count such as (3/3 Passed) or (1/3 Failed). |
| Console | Output of console.log from the Pre-Script and Post-Script. |
If DocStar can't reach the API, you see Could not send request. Check the URL, the selected environment and your network. To stop a slow request, click Cancel while it runs.
See Scripts to write tests and log values.
Save responses to your docs
- Add to Sample Response saves the current response as an example readers see in the published reference. You can change the status, description and body before you submit.
- Save as Example Request saves this version of the request under the endpoint in the sidebar.
Both buttons appear once the endpoint has been saved. To add a sample by hand, open Sample Response and click Add Sample Response. See Document an API Endpoint.
Cookies
DocStar doesn't have a separate cookie manager. You work with cookies through headers:
- Read cookies the API sets. Open the response Headers tab and look for
set-cookie. - Send cookies. In the request Headers tab, add a
Cookieheader, for exampleCookie: session={{sessionId}}. - Reuse a session cookie. Store it in an environment variable from a Post-Script, then reference it in the
Cookieheader:
const cookies = hm.response.headers.getHeaders()["set-cookie"];
if (cookies) {
const session = String(cookies).split(";")[0].split("=")[1];
hm.environment.set("sessionId", session);
}
Because most requests are sent through DocStar's server, cookies from your browser are not sent automatically. Add the ones you need yourself.
Tips
- If the body looks empty, check Raw. Non-JSON responses such as HTML or plain text read better there or in Preview.
- Compare the Headers tab with what you expect, such as
content-typeand cache headers. - Remove tokens and personal data from a response before you save it as a sample response.