Restful test with delete method

Hi, All:
I am facing a project which defined delete api with required body.

And I try to write script to run the test. However the katalon didn’t send the body to server. Do I have to using groovy or java to write the delete http request?

Or there is another way to do this?

Thanks

1 Like

Could you show the way the body was set up in your test scenario?

have the same problem, katalon does not send body in delete request .
i use java in script mode to build request.
DeleteRequest.setHttpBody(“body text”);

try use this

String URI = URI + “/accounts/delete”
String time = ZonedDateTime.now(ZoneOffset.UTC ).format( DateTimeFormatter.ISO_INSTANT )
RequestObject api = new RequestObject(“deleteAccount”)
api.setRestRequestMethod(“DELETE”)
api.setRestUrl(URI)

String body = “{\“sourceAccountNo\”: \”" + accountToDel +“\”,\“beneficiaryAccountNo\”: \“” + accountBeneficiary + “\”,\“naratif\”: \“” + “testing_remove " + accountToDel + “, trasfering to " + accountBeneficiary + “\”,\“user\”: \”” + “DCUS” + “\”,\“debetTransactionCode\”: \“” + “0000” + “\”,\“creditTransactionCode\”: \“” + “444” + “\”}"

ArrayList HTTPHeader = new ArrayList()
HTTPHeader.add(new TestObjectProperty(“Content-Type”, ConditionType.EQUALS, “application/json”))
HTTPHeader.add(new TestObjectProperty(“User-Agent”, ConditionType.EQUALS, “automation_script”))
HTTPHeader.add(new TestObjectProperty(“x-channel-id”, ConditionType.EQUALS, “111”))
HTTPHeader.add(new TestObjectProperty(“x-currency-fee”, ConditionType.EQUALS, “IDR”))
HTTPHeader.add(new TestObjectProperty(“x-reference-no”, ConditionType.EQUALS, getSecureRandom(“qe-automation”)))
HTTPHeader.add(new TestObjectProperty(“x-transmission-date-time”, ConditionType.EQUALS, time))
HTTPHeader.add(new TestObjectProperty(“x-fee”, ConditionType.EQUALS, “0”))
HTTPHeader.add(new TestObjectProperty(“x-node”, ConditionType.EQUALS, “xxx”))

api.setBodyContent(new HttpTextBodyContent(body))
api.setHttpHeaderProperties(HTTPHeader)

def response = WS.sendRequest(api)

aben test said:

have the same problem, katalon does not send body in delete request .
i use java in script mode to build request.
DeleteRequest.setHttpBody(“body text”);

I am also facing the same issue. Could you please share how did you resolve it.

alfiexu said:

Hi, All:
I am facing a project which defined delete api with required body.

And I try to write script to run the test. However the katalon didn’t send the body to server. Do I have to using groovy or java to write the delete http request?

Or there is another way to do this?

Thanks

Did you solve this issue? I have the same one. Please let me know how to resolve it.

Alex Jack said:

try use this

String URI = URI + “/accounts/delete”
String time = ZonedDateTime.now(ZoneOffset.UTC ).format( DateTimeFormatter.ISO_INSTANT )
RequestObject api = new RequestObject(“deleteAccount”)
api.setRestRequestMethod(“DELETE”)
api.setRestUrl(URI)

String body = “{\“sourceAccountNo\”: \”" + accountToDel +“\”,\“beneficiaryAccountNo\”: \“” + accountBeneficiary + “\”,\“naratif\”: \“” + “testing_remove " + accountToDel + “, trasfering to " + accountBeneficiary + “\”,\“user\”: \”” + “DCUS” + “\”,\“debetTransactionCode\”: \“” + “0000” + “\”,\“creditTransactionCode\”: \“” + “444” + “\”}"

ArrayList HTTPHeader = new ArrayList()
HTTPHeader.add(new TestObjectProperty(“Content-Type”, ConditionType.EQUALS, “application/json”))
HTTPHeader.add(new TestObjectProperty(“User-Agent”, ConditionType.EQUALS, “automation_script”))
HTTPHeader.add(new TestObjectProperty(“x-channel-id”, ConditionType.EQUALS, “111”))
HTTPHeader.add(new TestObjectProperty(“x-currency-fee”, ConditionType.EQUALS, “IDR”))
HTTPHeader.add(new TestObjectProperty(“x-reference-no”, ConditionType.EQUALS, getSecureRandom(“qe-automation”)))
HTTPHeader.add(new TestObjectProperty(“x-transmission-date-time”, ConditionType.EQUALS, time))
HTTPHeader.add(new TestObjectProperty(“x-fee”, ConditionType.EQUALS, “0”))
HTTPHeader.add(new TestObjectProperty(“x-node”, ConditionType.EQUALS, “xxx”))

api.setBodyContent(new HttpTextBodyContent(body))
api.setHttpHeaderProperties(HTTPHeader)

def response = WS.sendRequest(api)

This is not working for me.

1 Like

The current ‘Delete’ method does not support HTTP body as a parameter, you it will not work if you use body in this case

This issue has been fixed in Katalon Studio 5.7.1, please try again on that version.