{"id":9480,"date":"2022-04-04T07:05:26","date_gmt":"2022-04-04T07:05:26","guid":{"rendered":"https:\/\/thichblog.net\/?p=9480"},"modified":"2022-04-04T07:05:26","modified_gmt":"2022-04-04T07:05:26","slug":"api-testing-http-status-code-thuong-gap","status":"publish","type":"post","link":"https:\/\/vibeshelf.me\/?p=9480","title":{"rendered":"API Testing &#8211; HTTP Status Code th\u01b0\u1eddng g\u1eb7p"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\"><strong>HTTP Status Code l\u00e0 g\u00ec?<\/strong><\/h5>\n\n\n\n<p>HTTP Status Code theo ti\u1ebfng Vi\u1ec7t l\u00e0 &#8220;M\u00e3 tr\u1ea1ng th\u00e1i HTTP&#8221;. HTTP Status code s\u1ebd \u0111\u01b0\u1ee3c m\u00e1y ch\u1ee7 (server) tr\u1ea3 v\u1ec1 sau khi nh\u1eadn v\u00e0 phi\u00ean d\u1ecbch 1 y\u00eau c\u1ea7u HTTP t\u1eeb ph\u00eda m\u00e1y kh\u00e1ch (client).<\/p>\n\n\n\n<p>Theo \u0111\u00f3 HTTP status code  l\u00e0 m\u1ed9t m\u00e3 c\u00f3 3 ch\u1eef s\u1ed1. Ch\u1eef s\u1ed1 \u0111\u1ea7u ti\u00ean t\u1eeb 1 \u0111\u1ebfn 5 (t\u01b0\u01a1ng \u1ee9ng v\u1edbi 5 h\u1ea1ng m\u1ee5c \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh lo\u1ea1i ph\u1ea3n h\u1ed3i), 2 s\u1ed1 c\u00f2n gi\u1ea3i th\u00edch r\u00f5 chi ti\u1ebft cho ph\u1ea3n h\u1ed3i.<\/p>\n\n\n\n<p>\u0110\u1ec3 test API, ch\u00fang ta kh\u00f4ng nh\u1ea5t thi\u1ebft ph\u1ea3i bi\u1ebft h\u1ebft t\u1ea5t c\u1ea3 c\u00e1c HTTP Status code. Ch\u00fang ta ch\u1ec9 c\u1ea7n n\u1eafm \u0111\u01b0\u1ee3c ph\u1ea3n h\u1ed3i \u0111\u00f3 n\u1eb1m \u1edf h\u1ea1ng m\u1ee5c n\u00e0o, v\u00e0 m\u1ed9t v\u00e0i HTTP status code c\u1ee5 th\u1ec3 th\u01b0\u1eddng g\u1eb7p.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Sau \u0111\u00e2y l\u00e0 5 h\u1ea1ng m\u1ee5c c\u1ee7a HTTP status code:<\/strong><\/h5>\n\n\n\n<p>\u2013 <strong>1xx (100 \u2013 199): Information responses \/ Ph\u1ea3n h\u1ed3i th\u00f4ng tin<\/strong> \u2013 Y\u00eau c\u1ea7u \u0111\u00e3 \u0111\u01b0\u1ee3c ch\u1ea5p nh\u1eadn v\u00e0 qu\u00e1 tr\u00ecnh x\u1eed l\u00fd y\u00eau c\u1ea7u \u0111ang \u0111\u01b0\u1ee3c ti\u1ebfp t\u1ee5c.<\/p>\n\n\n\n<p>\u2013 <strong>2xx (200 \u2013 299): Successful responses \/ Ph\u1ea3n h\u1ed3i th\u00e0nh c\u00f4ng<\/strong> \u2013 Y\u00eau c\u1ea7u \u0111\u00e3 \u0111\u01b0\u1ee3c m\u00e1y ch\u1ee7 ti\u1ebfp nh\u1eadn, hi\u1ec3u v\u00e0 x\u1eed l\u00fd th\u00e0nh c\u00f4ng.<\/p>\n\n\n\n<p>\u2013 <strong>3xx (300 \u2013 399): Redirects \/ \u0110i\u1ec1u h\u01b0\u1edbng<\/strong> \u2013 Ph\u00eda client c\u1ea7n th\u1ef1c hi\u1ec7n h\u00e0nh \u0111\u1ed9ng b\u1ed5 sung \u0111\u1ec3 ho\u00e0n t\u1ea5t y\u00eau c\u1ea7u.<\/p>\n\n\n\n<p>\u2013 <strong>4xx (400 \u2013 499): Client errors \/ L\u1ed7i ph\u00eda client<\/strong> \u2013 Y\u00eau c\u1ea7u kh\u00f4ng th\u1ec3 ho\u00e0n t\u1ea5t ho\u1eb7c y\u00eau c\u1ea7u ch\u1ee9a c\u00fa ph\u00e1p kh\u00f4ng ch\u00ednh x\u00e1c.\u0110\u00e2y l\u00e0 l\u1ed7i t\u1eeb ph\u00eda client do y\u00eau c\u1ea7u kh\u00f4ng h\u1ee3p l\u1ec7.<\/p>\n\n\n\n<p>\u2013 <strong>5xx (500 \u2013 599): Server errors \/ L\u1ed7i ph\u00eda m\u00e1y ch\u1ee7<\/strong> \u2013 M\u00e1y ch\u1ee7 kh\u00f4ng th\u1ec3 ho\u00e0n th\u00e0nh y\u00eau c\u1ea7u \u0111\u01b0\u1ee3c cho l\u00e0 h\u1ee3p l\u1ec7. Khi 5xx x\u1ea3y ra, b\u1ea1n ch\u1ec9 c\u00f3 th\u1ec3 \u0111\u1ee3i \u0111\u1ec3 b\u00ean h\u1ec7 th\u1ed1ng m\u00e1y ch\u1ee7 x\u1eed l\u00fd xong.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>V\u00e0 ti\u1ebfp theo l\u00e0 nh\u1eefng HTTP Status Code c\u1ee5 th\u1ec3 th\u01b0\u1eddng g\u1eb7p:<\/strong><\/h5>\n\n\n\n<p>\u25cf <strong>200 \u2013 OK:<\/strong> Y\u00eau c\u1ea7u \u0111\u00e3 th\u00e0nh c\u00f4ng. V\u00e0 \u00fd ngh\u0129a th\u00e0nh c\u00f4ng s\u1ebd ph\u1ee5 thu\u1ed9c v\u00e0o ph\u01b0\u01a1ng th\u1ee9c HTTP (HTTP Method) <br>GET: T\u00e0i nguy\u00ean \u0111\u01b0\u1ee3c t\u00ecm va tr\u1ea3 v\u1ec1 th\u00e0nh c\u00f4ng.<br>POST\/PUT: H\u00e0nh \u0111\u1ed9ng t\u1ea1o, c\u1eadp nh\u1eadt d\u1eef li\u1ec7u th\u00e0nh c\u00f4ng.<\/p>\n\n\n\n<p>\u25cf<strong> 400 \u2013 Bad Request:<\/strong> Server kh\u00f4ng hi\u1ec3u y\u00eau c\u1ea7u x\u1eed l\u00fd do sai t\u1eeb ph\u00eda client nh\u01b0 sai d\u1eef li\u1ec7u (data type) hay thi\u1ebfu tham s\u1ed1 (missing parameter).<\/p>\n\n\n\n<p>\u25cf <strong>401 \u2013 Unauthorized: <\/strong>Ch\u01b0a \u0111\u01b0\u1ee3c x\u00e1c th\u1ef1c do y\u00eau c\u1ea7u thi\u1ebfu access token ch\u1eb3ng h\u1ea1n.<\/p>\n\n\n\n<p><strong>\u25cf 403 \u2013 Forbidden:<\/strong> Client kh\u00f4ng \u0111\u01b0\u1ee3c ph\u00e9p truy c\u1eadp v\u00e0o t\u00e0i nguy\u00ean y\u00eau c\u1ea7u.<\/p>\n\n\n\n<p><strong>\u25cf 404 \u2013 Not Found:<\/strong> Kh\u00f4ng t\u00ecm th\u1ea5y t\u00e0i nguy\u00ean y\u00eau c\u1ea7u.<\/p>\n\n\n\n<p>\u25cf <strong>500 \u2013 Server error:<\/strong> Th\u00f4ng b\u00e1o l\u1ed7i chung v\u1ec1 c\u00e1c v\u1ea5n \u0111\u1ec1 \u1edf ph\u00eda server, nh\u01b0 m\u00f4i tr\u01b0\u1eddng kh\u00f4ng ho\u1ea1t \u0111\u1ed9ng (thi\u1ebfu th\u01b0 vi\u1ec7n, kh\u00f4ng th\u1ec3 k\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u)<\/p>\n\n\n\n<p><strong>\u25cf 503 \u2013 Service Unavailable:<\/strong> M\u00e1y ch\u1ee7 t\u1ea1m th\u1eddi kh\u00f4ng ho\u1ea1t \u0111\u1ed9ng c\u00f3 th\u1ec3 do qu\u00e1 t\u1ea3i, server down \u0111\u1ec3 b\u1ea3o tr\u00ec.<\/p>\n\n\n\n<p>Tham kh\u1ea3o th\u00eam nh\u1eefng status code kh\u00e1c <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Status\" target=\"_blank\" rel=\"noreferrer noopener\">t\u1ea1i \u0111\u00e2y<\/a>. <\/p>\n\n\n\n<p class=\"has-text-align-right\">Happy Testing!<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>HTTP Status Code l\u00e0 g\u00ec? HTTP Status Code theo ti\u1ebfng Vi\u1ec7t l\u00e0 &#8220;M\u00e3 tr\u1ea1ng th\u00e1i HTTP&#8221;. HTTP Status code s\u1ebd \u0111\u01b0\u1ee3c m\u00e1y ch\u1ee7 (server) tr\u1ea3 v\u1ec1 sau khi nh\u1eadn v\u00e0 phi\u00ean d\u1ecbch 1 y\u00eau c\u1ea7u HTTP t\u1eeb ph\u00eda m\u00e1y kh\u00e1ch (client). Theo \u0111\u00f3 HTTP status code l\u00e0 m\u1ed9t m\u00e3 c\u00f3 3 ch\u1eef s\u1ed1. Ch\u1eef s\u1ed1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9271,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[19,25,331],"class_list":["post-9480","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-testing","tag-api-testing","tag-back-end-testing","tag-kiem-thu-phan-mem"],"_links":{"self":[{"href":"https:\/\/vibeshelf.me\/index.php?rest_route=\/wp\/v2\/posts\/9480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vibeshelf.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vibeshelf.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vibeshelf.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vibeshelf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9480"}],"version-history":[{"count":0,"href":"https:\/\/vibeshelf.me\/index.php?rest_route=\/wp\/v2\/posts\/9480\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vibeshelf.me\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/vibeshelf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vibeshelf.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vibeshelf.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}