如何在Katlon Studio中上载REST API的文件

问题描述 投票:1回答:1

我尝试使用以下代码验证我的一个REST API负责上传文件,

def builder = new RestRequestObjectBuilder()

//Create a new POST object using builder
def requestObject = builder.withRestRequestMethod('POST')
.withRestUrl(GlobalVariable.APIurl + '/add_track')
.withHttpHeaders([
  new TestObjectProperty('Content-Type', ConditionType.EQUALS, 'multipart/form-data'),
         new TestObjectProperty('key', ConditionType.EQUALS, GlobalVariable.key),
         new TestObjectProperty('token', ConditionType.EQUALS, GlobalVariable.token)])

.withMultipartFormDataBodyContent([
    new FormDataBodyParameter('file',"C:\\SampleAudio.mp3" , 'File'),
    new FormDataBodyParameter('description', 'This track is uploaded by automation',  'PARAM_TYPE_TEXT'),
    new FormDataBodyParameter( 'title', 'being single', 'PARAM_TYPE_TEXT'),
])
.build()

def response =WS.sendRequest(requestObject)
WS.verifyResponseStatusCode(response, 200)
WS.verifyElementPropertyValue(response, "message", "test")

但是文件未发布在服务器上,我尝试了所有可能的方法,但没有运气。

automation build-automation katalon-studio
1个回答
0
投票
看来,这实际上是Katalon工作室Request Builder中的错误。您是否为此找到了工作?
© www.soinside.com 2019 - 2024. All rights reserved.