Katalon Studio - Невозможно отправить тестовый запрос: неверное начало или конец - PullRequest
0 голосов
/ 16 октября 2018

Я пытаюсь отправить веб-запрос 'POST' на определенный адрес (например: https://qa.alycedev.com/)

. Любые установленные свойства (заголовок, тело, файлы cookie, URL-кодирование / декодирование) приводят к ошибке при отправкемой веб-запрос:

Предупреждение> Невозможно отправить тестовый запрос. Причина: java.lang.IllegalArgumentException: неверное начало или конец.

Ниже вы можете найти подробную информацию об ошибке: https://i.stack.imgur.com/szGan.png

Пример моего запроса:

@Keyword
def purchase_simple (def totalCookies) {
    WebUI.comment('Total number of cookies=' +totalCookies.size())
    RequestObject ro = new RequestObject('A')
    ro.setRestRequestMethod('POST')
    ro.setRestUrl('https://qa.alycedev.com/gifter/dashboard')
    def httpheader = new ArrayList<TestObjectProperty>()
    httpheader.add(new TestObjectProperty('Content-Type', ConditionType.EQUALS, 'application/json'))
    httpheader.add(new TestObjectProperty('Accept', ConditionType.EQUALS, 'application/json'))
    for (Cookie currentCookie : totalCookies) {
        httpheader.add(new TestObjectProperty('Cookie', ConditionType.EQUALS, 'domain='+currentCookie.getDomain() + '; '+currentCookie.getName() + '=' + currentCookie.getValue() + '; expires='+currentCookie.getExpiry() + '; Max-Age=7200; path=/;'))
    }
    ro.setHttpHeaderProperties(httpheader)
    def body = '{"_token": "' + GlobalVariable.G_api_oauth.csrfToken + '","use_credits": ' + GlobalVariable.G_product.price + ',"use_payment": 0.00,"currency_id": 1,"total_price": ' + GlobalVariable.G_product.price + ',"payment_data" : null,"gift_send_data": "{"id":' + GlobalVariable.G_gift.id + ',"product_id":' + GlobalVariable.G_product.id + ',"total_price":' + GlobalVariable.G_product.price + ',"send_now":true,"schedule_at":"","send_type":"hwcard","gifter_company":"Apple","giftee_company":"Sony","from":null,"gifter_address":{"country":{"id":1,"name":"United States","code":"US","image":""},"country_id":1,"address":"Address","address2":"Address 2","city":"City","state":"State","zipcode":"123321"},"giftee_address":{"country":{"id":1,"name":"United States","code":"US","image":""},"country_id":1,"address":"Address","address2":"Address 2","city":"City","state":"State","zipcode":"123321"},"message_to_giftee":{"id":1,"default":1,"message":"Messages subject + 10 characters.","subject":"Something for your time","name":"Something for your time"},"prospect":{"capture_date":true,"capture_email":true,"capture_phone":true,"capture_question":false,"capture_affidavit":false,"gifter_affidavit":"","gifter_question":""},"delivery_method_data":{"type":"branded_box"}}"}'
    ro.setBodyContent(new HttpTextBodyContent(body, 'UTF-8', 'application/json'))

    WebUI.comment(ro.activeProperties.toArray().toString())
    try{
        def response = WSBuiltInKeywords.sendRequest(ro)
    }
    catch(Exception ex) {
        println(ex.detailMessage)
        println(ex.stackTraceDepth.toString())
    }
}
...