PageSourceSearch

https://docs-production-katalon.netlify.app/assets/js/a95b2cba.a4f78780.js

js docs-production-katalon.netlify.app collected 2026-10-03 10:42:24 UTC 8,301 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkKatalon_Docs=self.webpackChunkKatalon_Docs||[]).push([[9570],{28453:(e,t,s)=>{s.d(t,{R:()=>i,x:()=>r});var n=s(96540);const o={},a=n.createContext(o);function i(e){const t=n.useContext(a);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function r(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),n.createElement(a.Provider,{value:t},e.children)}},45572:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>d,frontMatter:()=>i,metadata:()=>n,toc:()=>p});const n=JSON.parse('{"id":"test-objects/api-test-objects/create-web-service-object-in-katalon-studio-script-mode","title":"Create Web Service Object in Katalon Studio Script Mode","description":"Katalon Studio provides API testing capabilities with REST and   SOAP services which are easily accessible through an intuitive User   Interface. However, you can also create and manipulate such web   service objects directly within test cases in script view.","source":"@site/docs/katalon-studio/test-objects/api-test-objects/create-web-service-object-in-katalon-studio-script-mode.md","sourceDirName":"test-objects/api-test-objects","slug":"/test-objects/api-test-objects/create-web-service-object-in-katalon-studio-script-mode","permalink":"/katalon-studio/test-objects/api-test-objects/create-web-service-object-in-katalon-studio-script-mode","draft":false,"unlisted":false,"tags":[],"version":"current","lastUpdatedAt":1758935351000,"frontMatter":{"title":"Create Web Service Object in Katalon Studio Script Mode"},"sidebar":"katalon-studio","previous":{"title":"Web Services Builder in Katalon Studio","permalink":"/katalon-studio/test-objects/api-test-objects/web-services-builder-in-katalon-studio"},"next":{"title":"Schema compliance testing in Katalon Studio","permalink":"/katalon-studio/test-objects/api-test-objects/schema-compliance-testing-in-katalon-studio"}}');var o=s(74848),a=s(28453);const i={title:"Create Web Service Object in Katalon Studio Script Mode"},r=void 0,c={},p=[];function l(e){const t={a:"a",...(0,a.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{xmlns:"http://www.w3.org/1999/xhtml",className:"p",children:"Katalon Studio provides API testing capabilities with REST and   SOAP services which are easily accessible through an intuitive User   Interface. However, you can also create and manipulate such web   service objects directly within test cases in script view."}),"\n",(0,o.jsx)("p",{xmlns:"http://www.w3.org/1999/xhtml",className:"p",children:"The following example demonstrates how to create, send and   verify a simple request to Jira Web Service API. You can see the   result for yourself following the steps below:"}),"\n",(0,o.jsxs)("ul",{xmlns:"http://www.w3.org/1999/xhtml",className:"ul",children:[(0,o.jsx)("li",{className:"li",children:"Open Katalon Studio."}),(0,o.jsx)("li",{className:"li",children:"Open a test case."}),(0,o.jsx)("li",{className:"li",children:"Switch to Script mode."}),(0,o.jsx)("li",{className:"li",children:"Copy and paste the following code."}),(0,o.jsx)("li",{className:"li",children:"Execute the test case."})]}),"\n",(0,o.jsx)("pre",{xmlns:"http://www.w3.org/1999/xhtml",className:"pre codeblock",children:(0,o.jsxs)("code",{children:["import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint","\n","import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase","\n","import static com.kms.katalon.core.testdata.TestDataFactory.findTestData","\n","import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject","\n","import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint","\n","import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW","\n","import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile","\n","import com.kms.katalon.core.model.FailureHandling as FailureHandling","\n","import com.kms.katalon.core.testcase.TestCase as TestCase","\n","import com.kms.katalon.core.testdata.TestData as TestData","\n","import com.kms.katalon.core.testobject.ConditionType","\n","import com.kms.katalon.core.testobject.HttpBodyContent","\n","import com.kms.katalon.core.testobject.impl.HttpTextBodyContent","\n","import com.kms.katalon.core.testobject.RequestObject","\n","import com.kms.katalon.core.testobject.TestObjectProperty","\n","import com.kms.katalon.core.testobject.TestObject as TestObject","\n","import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS","\n","import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI","\n","import internal.GlobalVariable as GlobalVariable","\n","import java.util.List","\n","import java.util.ArrayList","\n","import java.util.HashMap","\n","\n","// Put body content properties into a map","\n","HashMap<String, Object> innerBodyContentMap = new HashMap<>();","\n","HashMap<String, Object> projectMap = new HashMap<>();","\n","projectMap.put('key', 'KD')","\n","innerBodyContentMap.put('project', projectMap)","\n","\n","innerBodyContentMap.put('summary', 'REST - Create new issue using API')","\n","innerBodyContentMap.put('description', 'Creating of an issue using project keys and issue type names using the REST API')","\n","\n","HashMap<String, Object> issueTypeMap = new HashMap<>()","\n","issueTypeMap.put('name', 'Story')","\n","innerBodyContentMap.put('issuetype', issueTypeMap)","\n","\n","\n","HashMap<String, Object> priorityMap = new HashMap<>()","\n","priorityMap.put('name', 'High')","\n","innerBodyContentMap.put('priority', priorityMap)","\n","\n","// Convert map into Json","\n","def jsonBodyContent = new groovy.json.JsonBuilder()","\n","jsonBodyContent fields: innerBodyContentMap","\n","\n","// Convert Json into String ","\n","String bodyContent =","  ","jsonBodyContent.toString()","\n","// Create body content property","\n","HttpTextBodyContent httpBodyContent = new HttpTextBodyContent(bodyContent);","\n","\n","// Create header properties","\n","List<TestObjectProperty> httpHeaderProperties = new ArrayList<>()","\n","httpHeaderProperties.add(new TestObjectProperty(\"Content-Type\", ConditionType.EQUALS, 'application/json'))","\n","httpHeaderProperties.add(new TestObjectProperty(\"Authorization\", ConditionType.EQUALS, 'Basic ZGVtb0BrYXRhbG9uLmNvbTpWQm5jZXRPU083MEU0TlZMWVFuaDlCMkQ='))","\n","\n","RequestObject scriptedWso = new RequestObject('Create a new issue with script')","\n","scriptedWso.setBodyContent(httpBodyContent)","\n","scriptedWso.setServiceType('REST')","\n","scriptedWso.setHttpHeaderProperties(httpHeaderProperties)","\n","scriptedWso.setRestUrl('",(0,o.jsx)(t.a,{href:"https://katalon.atlassian.net/rest/api/2/issue/?')%7B%22%5Cn%22%7DscriptedWso.setRestRequestMethod('POST')%7B%22%5Cn%22%7D%7B%22%5Cn%22%7D//",children:'https://katalon.atlassian.net/rest/api/2/issue/?\'){"\\n"}scriptedWso.setRestRequestMethod(\'POST\'){"\\n"}{"\\n"}//'})," Send the request and get the response","\n","response = WS.sendRequest(scriptedWso)","\n","\n","// Verify the response","\n","WS.verifyResponseStatusCode(response, 201)","\n","// Result: Test case successfully executed ","\n"]})}),"\n",(0,o.jsx)("p",{xmlns:"http://www.w3.org/1999/xhtml",className:"p",children:"The test case will be executed successfully. You can achieve the   same result by manually creating a Web Service Object then add the   same information. These manually created objects will be saved in   repository and are easily referenced in test cases without huge   chunk of code."}),"\n",(0,o.jsx)("p",{xmlns:"http://www.w3.org/1999/xhtml",className:"p",children:"However, if you are interested in a one time request without the   reusability, then programmatically creating a web service object is   a good practice. If you desire both reusability and   customizability, you can create your own Custom Keyword that builds   a Web Service Object in the above manner and call it in your test   cases. You also can use the code above in any other place with a   script view (Custom Keyword, Test Listener). This allows more   flexibility in your test automation projects."})]})}function d(e={}){const{wrapper:t}={...(0,a.R)(),...e.components};return t?(0,o.jsx)(t,{...e,children:(0,o.jsx)(l,{...e})}):l(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.