{"id":3401,"date":"2019-07-09T03:46:57","date_gmt":"2019-07-09T03:46:57","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=3401"},"modified":"2024-11-29T13:26:10","modified_gmt":"2024-11-29T13:26:10","slug":"how-to-fix-400-bad-request-error-in-testlink-api","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-fix-400-bad-request-error-in-testlink-api\/","title":{"rendered":"How to fix 400 Bad request error in TestLink API"},"content":{"rendered":"<h2>How to fix 400 Bad request error in TestLink API<\/h2>\n<p>In this tutorial, we will look at a sample issue and fix 400 Bad request errors in executing the TestLink REST API request.<\/p>\n<h3>Error<\/h3>\n<p>Let&#8217;s take an example API call:<\/p>\n<p>\/testlink\/lib\/api\/rest\/v2\/superman<\/p>\n<p>This call is used to check the REST API is working on the TestLink Server instance.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3405\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/400-Bad-Reuest-TestLink-API.png\" alt=\"400 Bad Request TestLink API\" width=\"1854\" height=\"903\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/400-Bad-Reuest-TestLink-API.png 1854w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/400-Bad-Reuest-TestLink-API-300x146.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/400-Bad-Reuest-TestLink-API-1024x499.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/400-Bad-Reuest-TestLink-API-768x374.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/400-Bad-Reuest-TestLink-API-1536x748.png 1536w\" sizes=\"auto, (max-width: 1854px) 100vw, 1854px\" \/><\/p>\n<h3><\/h3>\n<h3>Apache Access Log<\/h3>\n<p>Apache access log entry would be something similar to:<\/p>\n<p>&#8220;GET \/testlink\/lib\/api\/rest\/v2\/superman HTTP\/1.1&#8221; 400 326 &#8220;-&#8221; &#8220;PostmanRuntime\/7.26.1&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p>To view the access log we can use the following command:<\/p>\n<p>Go to the directory path of the Apache access log.<\/p>\n<p>Issue the following command:<\/p>\n<p><strong>$ tail -f access.log<\/strong><\/p>\n<p>We need to take the clue from the Response body which says &#8216;authentication error&#8217;. Ideally, standard Rest API endpoints respond with 401 Unauthorized response code fro authentication problems.<\/p>\n<h3>Fix<\/h3>\n<p>Check the API key that you have provided as an HTTP header. It should match exactly with the key that you have generated on the TestLink server instance. <strong><a href=\"https:\/\/www.testingdocs.com\/testlink-api\/\">(https:\/\/www.testingdocs.com\/testlink-api\/)<\/a><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3412\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Superman-Rest-API-call-sucess.png\" alt=\"\" width=\"1846\" height=\"751\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Superman-Rest-API-call-sucess.png 1846w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Superman-Rest-API-call-sucess-300x122.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Superman-Rest-API-call-sucess-1024x417.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Superman-Rest-API-call-sucess-768x312.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Superman-Rest-API-call-sucess-1536x625.png 1536w\" sizes=\"auto, (max-width: 1846px) 100vw, 1846px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to fix 400 Bad request error in TestLink API : In this tutorial, we will look at a sample issue and fix 400 Bad request errors in executing<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[212],"class_list":["post-3401","post","type-post","status-publish","format-standard","hentry","category-testlink","tag-testlink","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/3401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=3401"}],"version-history":[{"count":9,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/3401\/revisions"}],"predecessor-version":[{"id":26206,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/3401\/revisions\/26206"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=3401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=3401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=3401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}