{
  "name": "04 - HTTP Request and API Testing",
  "nodes": [
    {
      "parameters": {
        "content": "## 04 HTTP Request and APIs\nGET a post, use its data in a POST, then assert like a tester:\n- status code is 201\n- response title matches what we sent\n\nFull Response is ON so you can see statusCode, headers, body.",
        "height": 220,
        "width": 440
      },
      "id": "04000000-0000-4000-8000-000000000000",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-60, -280]
    },
    {
      "parameters": {},
      "id": "04000000-0000-4000-8000-000000000001",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [0, 0]
    },
    {
      "parameters": {
        "url": "https://jsonplaceholder.typicode.com/posts/1",
        "options": { "response": { "response": { "fullResponse": true } } }
      },
      "id": "04000000-0000-4000-8000-000000000002",
      "name": "GET Post",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [220, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://jsonplaceholder.typicode.com/posts",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: 'Created from n8n', body: 'Copied from post ' + $json.body.id, userId: $json.body.userId }) }}",
        "options": { "response": { "response": { "fullResponse": true } } }
      },
      "id": "04000000-0000-4000-8000-000000000003",
      "name": "POST Create",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [440, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "loose", "version": 2 },
          "conditions": [
            {
              "id": "04a00000-0000-4000-8000-000000000001",
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 201,
              "operator": { "type": "number", "operation": "equals" }
            },
            {
              "id": "04a00000-0000-4000-8000-000000000002",
              "leftValue": "={{ $json.body.title }}",
              "rightValue": "Created from n8n",
              "operator": { "type": "string", "operation": "equals" }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "04000000-0000-4000-8000-000000000004",
      "name": "Assert Response",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [660, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "04b00000-0000-4000-8000-000000000001", "name": "result", "value": "PASS", "type": "string" },
            { "id": "04b00000-0000-4000-8000-000000000002", "name": "createdId", "value": "={{ $json.body.id }}", "type": "number" }
          ]
        },
        "options": {}
      },
      "id": "04000000-0000-4000-8000-000000000005",
      "name": "PASS",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [880, -100]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "04c00000-0000-4000-8000-000000000001", "name": "result", "value": "FAIL", "type": "string" },
            { "id": "04c00000-0000-4000-8000-000000000002", "name": "gotStatus", "value": "={{ $json.statusCode }}", "type": "number" }
          ]
        },
        "options": {}
      },
      "id": "04000000-0000-4000-8000-000000000006",
      "name": "FAIL",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [880, 100]
    }
  ],
  "connections": {
    "Start": { "main": [[{ "node": "GET Post", "type": "main", "index": 0 }]] },
    "GET Post": { "main": [[{ "node": "POST Create", "type": "main", "index": 0 }]] },
    "POST Create": { "main": [[{ "node": "Assert Response", "type": "main", "index": 0 }]] },
    "Assert Response": {
      "main": [
        [{ "node": "PASS", "type": "main", "index": 0 }],
        [{ "node": "FAIL", "type": "main", "index": 0 }]
      ]
    }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "active": false
}
