Get Random Joke

GET https://official-joke-api.appspot.com/random_joke

Get a Random Joke

This request retrieves a random joke from the Official Joke API.

Request Details

  • Method: GET

  • URL: https://official-joke-api.appspot.com/random_joke

Parameters

No parameters are required for this request.

Headers

No headers are required for this request.

Example Response

A successful response will include a random joke in JSON format:

  1. Send the Request:
- Click the **"Send"** button to send the request and receive a response.
  1. Save the Example Response:
- After receiving a successful response, scroll down to the response section at the bottom of the Qodex interface.

- Click the **"Save Response"** button (it looks like a floppy disk icon) next to the response tabs (Body, Cookies, Headers, Test Results).

- Name the response example (e.g., "Successful Response Example") and click **"Save Example"**.

Verifying and Troubleshooting

  1. Ensure the Example is Saved:
- Go to the `Examples` tab of the request to verify that the example response has been saved.
  1. Resend the Request:
- Resend the request to ensure everything is working as expected.

Example Test Script

Add this script under the Tests tab to verify the response and saved example:

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
// Verify documentation
pm.test("Check documentation", function () {
    const documentation = pm.collectionVariables.get('documentation');
    pm.expect(documentation).to.not.be.empty;
    pm.expect(documentation).to.include("Get a Random Joke");
    pm.expect(documentation).to.include("This request retrieves a random joke from the Official Joke API.");
    pm.expect(documentation).to.include("Method: GET");
    pm.expect(documentation).to.include("URL: https://official-joke-api.appspot.com/random_joke");
    pm.expect(documentation).to.include("No parameters are required for this request.");
    pm.expect(documentation).to.include("A successful response will include a random joke in JSON format:");
});
// Verify saved example
const savedExample = pm.response.json();
pm.test("Check saved example", function () {
    pm.expect(savedExample).to.be.an('object');
    pm.expect(savedExample).to.have.property('id');
    pm.expect(savedExample).to.have.property('type');
    pm.expect(savedExample).to.have.property('setup');
    pm.expect(savedExample).to.have.property('punchline');
});
``` json
{
  "id": 10,
  "type": "general",
  "setup": "Why don’t scientists trust atoms?",
  "punchline": "Because they make up everything!"
}

  1. Send the Request:
- Click the **"Send"** button to send the request and receive a response.
  1. Save the Example Response:
- After receiving a successful response, scroll down to the response section at the bottom of the Qodex interface.

- Click the **"Save Response"** button (it looks like a floppy disk icon) next to the response tabs (Body, Cookies, Headers, Test Results).

- Name the response example (e.g., "Successful Response Example") and click **"Save Example"**.

RESPONSES

status: OK

{"type":"general","setup":"What's red and bad for your teeth?","punchline":"A Brick.","id":268}