{"__v":1,"_id":"55fc9b7b3c21291900e7e0e8","category":{"__v":1,"_id":"55fc9b7a3c21291900e7e0de","pages":["55fc9b7b3c21291900e7e0e8","55fc9b7b3c21291900e7e0e9","55fc9b7b3c21291900e7e0ea","55fc9b7b3c21291900e7e0eb","55fc9b7b3c21291900e7e0ec"],"project":"5553d36165e8260d0024419a","version":"55fc9b793c21291900e7e0d7","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-05-14T20:15:44.034Z","from_sync":false,"order":6,"slug":"conditions","title":"Conditions"},"parentDoc":null,"project":"5553d36165e8260d0024419a","user":"5553d33065e8260d00244199","version":{"__v":12,"_id":"55fc9b793c21291900e7e0d7","project":"5553d36165e8260d0024419a","createdAt":"2015-09-18T23:17:13.545Z","releaseDate":"2015-09-18T23:17:13.545Z","categories":["55fc9b7a3c21291900e7e0d8","55fc9b7a3c21291900e7e0d9","55fc9b7a3c21291900e7e0da","55fc9b7a3c21291900e7e0db","55fc9b7a3c21291900e7e0dc","55fc9b7a3c21291900e7e0dd","55fc9b7a3c21291900e7e0de","55fc9b7a3c21291900e7e0df","55fc9b7a3c21291900e7e0e0","55fc9b7a3c21291900e7e0e1","55fc9b7a3c21291900e7e0e2","55fc9b7a3c21291900e7e0e3","55fc9bad4c80910d00b9bece","56394a0c3539050d00082122","56394a2f68b11f0d0048c9ff","56394a462fc5520d001a4db3","56394a4c2fc5520d001a4db4","56394a5b049e420d00476b5c","56394a6a2fc5520d001a4db5","56394f791593e4190073a44b","567b3adfb56bac0d0019d8d9","569d590e5a2b060d008741eb","569ea93dffccd10d00a05c7f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.0.0","version":"2"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-05-14T20:25:31.566Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"Conditions are set from the Conditions tab in the Call editing screen.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/sYbE9b4EQwyon44wMekz_Screen%20Shot%202015-12-23%20at%203.58.48%20PM.png\",\n        \"Screen Shot 2015-12-23 at 3.58.48 PM.png\",\n        \"1170\",\n        \"396\",\n        \"#3b4496\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"HTTP Codes\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Default Pass\",\n  \"body\": \"If the HTTP Code is in the range 200-299, APImetrics will record a pass.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Warnings\",\n  \"body\": \"HTTP Code range 400-499\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Error\",\n  \"body\": \"HTTP Codes in range 500-599\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Setting Custom Error Codes\"\n}\n[/block]\nThere may be cases where you may expect a 400 error, but want to mark it as a passor perhaps mark a test as a failure if it returns a 204 code.\n\nTo set this up, go to the Call Edit page and select the Conditions tab. \n\nFirst, in the Source drop-down select HTTP Status Code.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Operators\",\n  \"body\": \"== is used for testing the equality of two values\"\n}\n[/block]\n\nEnter a number (for instance, 204) in the value field on the right of it.\n\nThe “On true” and “On false” fields may be optionally set to override the test result to a pass, fail or warning. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ZnW30kuCSbaKMKVuU12t_Screen%20Shot%202015-12-23%20at%204.16.12%20PM.png\",\n        \"Screen Shot 2015-12-23 at 4.16.12 PM.png\",\n        \"573\",\n        \"154\",\n        \"#3e3e91\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nExample:\n\nYou have entered == 204 and a test result with HTTP code 204 occurs. The result will be the value you chose for “On true” if you set it.\n\nYou may set multiple conditions. They are compared in order as on the page, so one condition may override an earlier one in the list. For this reason, we recommend you use the \"<No Change>\" option for \"On true\" or \"On false\" for the passing case unless you want to override a failing API Call.","excerpt":"Handling conditions in an API call","slug":"handling-api-call-conditions-alerts-errors-and-var","type":"basic","title":"Setting Conditions on a Call"}

Setting Conditions on a Call

Handling conditions in an API call

Conditions are set from the Conditions tab in the Call editing screen. [block:image] { "images": [ { "image": [ "https://files.readme.io/sYbE9b4EQwyon44wMekz_Screen%20Shot%202015-12-23%20at%203.58.48%20PM.png", "Screen Shot 2015-12-23 at 3.58.48 PM.png", "1170", "396", "#3b4496", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "HTTP Codes" } [/block] [block:callout] { "type": "success", "title": "Default Pass", "body": "If the HTTP Code is in the range 200-299, APImetrics will record a pass." } [/block] [block:callout] { "type": "warning", "title": "Warnings", "body": "HTTP Code range 400-499" } [/block] [block:callout] { "type": "danger", "title": "Error", "body": "HTTP Codes in range 500-599" } [/block] [block:api-header] { "type": "basic", "title": "Setting Custom Error Codes" } [/block] There may be cases where you may expect a 400 error, but want to mark it as a passor perhaps mark a test as a failure if it returns a 204 code. To set this up, go to the Call Edit page and select the Conditions tab. First, in the Source drop-down select HTTP Status Code. [block:callout] { "type": "info", "title": "Operators", "body": "== is used for testing the equality of two values" } [/block] Enter a number (for instance, 204) in the value field on the right of it. The “On true” and “On false” fields may be optionally set to override the test result to a pass, fail or warning. [block:image] { "images": [ { "image": [ "https://files.readme.io/ZnW30kuCSbaKMKVuU12t_Screen%20Shot%202015-12-23%20at%204.16.12%20PM.png", "Screen Shot 2015-12-23 at 4.16.12 PM.png", "573", "154", "#3e3e91", "" ] } ] } [/block] Example: You have entered == 204 and a test result with HTTP code 204 occurs. The result will be the value you chose for “On true” if you set it. You may set multiple conditions. They are compared in order as on the page, so one condition may override an earlier one in the list. For this reason, we recommend you use the "<No Change>" option for "On true" or "On false" for the passing case unless you want to override a failing API Call.