Cannot print api response on console

26 views
Skip to first unread message

Pullabhotla Srinivas

unread,
Jun 4, 2017, 10:42:27 PM6/4/17
to Selenium Users

For some reason, when I try to print the response using print statement for the response body, the system does not print. please help.

In the following API post, I am using Java, rest-assured, TestNG on Eclipse Neon 3. Using @DataProvider annotation, I am passing multiple params in Post request to see the response of the call. Any help would be greatly appreciated.


Here is the code :


package com.auto.restassured;

import io.restassured.RestAssured;
import static io.restassured.RestAssured.basic;
import static io.restassured.RestAssured.given;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import io.restassured.response.Response;
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;


public class FilePostToVirusTotal {


static String baseURL = "https://www.virustotal.com/vtapi/v2/file/report";
Response myResponse;


@DataProvider(name = "md5hashes")
public String[][] createMd5Hashes() {

    return new String[][]  {

        {"md51", "c1105fb75bc00b5e487f7b26a5be7088"},
        {"md52", "213f3287c81d09b095334c9f3151cff8"},
        {"md53", "b00c2c458b4cf1eb172e354f54f0fe12"},
        {"md54", "32ac9b6b6b7cdbfce179acc5edae98c3"},
        {"md55", "510b0b81b85c025d538ed4bad78dc64f"},

    };

}

@Test(dataProvider = "md5hashes")
public void md5JsonTest(String apikey, String resource)
{

    //Catch API response
    myResponse = given().param("text", resource).param("text", "34b937e6e2d28ee6f93a70392d958de8ac4a8dd842e08bbca9bcb0d22f9b9960").when().post(baseURL);
    //Print Response
    System.out.println(myResponse.getBody().asString());

}
}



Krishnan Mahadevan

unread,
Jun 4, 2017, 10:49:40 PM6/4/17
to seleniu...@googlegroups.com

Please help keep this forum relevant by posting queries that are ONLY related to Selenium/WebDriver.

Your question is not related to Selenium/WebDriver. You might want to post this query on a Rest-assured related forum.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1431f048-0b41-4835-97db-2440135cca9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Doug Dragon

unread,
Jun 5, 2017, 1:26:14 PM6/5/17
to Selenium Users
You may find what you're looking for in this SO thread: https://stackoverflow.com/a/26488661/2573711
Reply all
Reply to author
Forward
0 new messages