Simple hello world

Hi, thank you for your brilliant efforts. I’m looking forward to evaluating your tool. Reading the docs, i’ve cobbled together the following yml:

id: "transaction-one"
variables:
  api_url: "https://jsonplaceholder.typicode.com"
steps:
  - id: "get user with id 1"
    request:
      method: "GET"
      endpoint: "{{ var.api_url }}/users/1"
    expect:
      code: 200
      body:
        type: "json"
        content: |
          {
            "first_name": "Bobby",
            "last_name": "Hounslow",
            "address": {
                "postcode": "TW4 7AE",
                "country": "UK",
            }
          }
    export:
      auth_header: "response.headers.X-APIDAUTH"
      auth_token: "response.body.access_token"

But on executing it via docker, i get

successful transactions: 0/0
failed transactions:     0/0

Can you help explain what I did wrong and also could you add a hello world sample somewhere please?

Hi!

Thanks for the brilliant question!

The way the APId config works is the following:

  • a config is comprised of a number of transactions
  • a transaction is comprised of a number of steps

It looks like you’ve correctly defined a step, but the steps definition needs to be wrapped in a transaction :slight_smile:

Also, we’ve updated the way you validate the result of a step to allow for more flexibility. Please refer to the docs here for more info!

I’ve updated the yaml to match the latest schema and executing it returns the following:

id: "transaction-one"
variables:
  api_url: "https://jsonplaceholder.typicode.com"
transactions:
  - id: "simple-transaction"
    steps:
      - id: "get user with id 1"
        request:
          method: "GET"
          endpoint: "{{ var.api_url }}/users/1"
        expect:
          code: 200
          body:
            - subset: true
              is: |
                {
                  "first_name": "Bobby",
                  "last_name": "Hounslow",
                  "address": {
                      "postcode": "TW4 7AE",
                      "country": "UK",
                  }
                }
        export:
          auth_header: "response.headers.X-APIDAUTH"
          auth_token: "response.body.access_token"
    FAIL get user with id 1

         request: GET https://jsonplaceholder.typicode.com/users/1 
         errors:
             body:
                expected value for body doesn't match actual:
                want:
                "{\n  \"first_name\": \"Bobby\",\n  \"last_name\": \"Hounslow\",\n  \"address\": {\n      \"postcode\": \"TW4 7AE\",\n      \"country\": \"UK\",\n  }\n}\n"
                received:
                {
                  "address": {
                    "city": "Gwenborough",
                    "geo": {
                      "lat": "-37.3159",
                      "lng": "81.1496"
                    },
                    "street": "Kulas Light",
                    "suite": "Apt. 556",
                    "zipcode": "92998-3874"
                  },
                  "company": {
                    "bs": "harness real-time e-markets",
                    "catchPhrase": "Multi-layered client-server neural-net",
                    "name": "Romaguera-Crona"
                  },
                  "email": "Sincere@april.biz",
                  "id": 1,
                  "name": "Leanne Graham",
                  "phone": "1-770-736-8031 x56442",
                  "username": "Bret",
                  "website": "hildegard.org"
                }
            
successful transactions: 0/1
failed transactions:     1/1