0

I'm trying to send 'POST' web request to specific address (for example: https://qa.alycedev.com/)

Any properties set (header, body, cookies, url encode/decode) leads to error while sending my web request:

Warning > Cannot send the test request. Reason: java.lang.IllegalArgumentException: invalid start or end.

Below you can find details of error: https://i.stack.imgur.com/szGan.png

Example of my request:

@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())
    }
}
Nikita
  • 5
  • 3

0 Answers0