HackerRank

FREE
By hackerrank | Updated a month ago | Tools
Popularity

7.2 / 10

Latency

355ms

Service Level

100%

Health Check

N/A

Back to All Discussions

I am not able to do request on hackerrank api for code submission .

Rapid account: Masterjavamayank
masterjavamayank
7 years ago

Test Program code is โ€ฆ

public class HackerTest {

public static void main(String[] args) {
	try{
		
		
		String apiKey = "my api key";
		String source = "class Test{public static void main(String args[]){System.out.println(\"Hello!\");}}";
		
		
		source = URLEncoder.encode(source,"UTF-8");
		Integer lang = new Integer(3);
		
		String testcases = "[\"Hello!\"]";
		testcases = URLEncoder.encode(testcases,"UTF-8");
		String format = "json";
		String wait = "true";
		String l_response = null;
		
		Map<String,Object> l_input_map = new HashMap<String, Object>();
		l_input_map.put("source", String.valueOf(source));
		l_input_map.put("lang", String.valueOf(lang));
		l_input_map.put("testcases", String.valueOf(testcases));
		l_input_map.put("api_key", String.valueOf(apiKey));
		l_input_map.put("wait", String.valueOf(wait));
		l_input_map.put("callback_url", "");
		l_input_map.put("format",String.valueOf(format));
		
		HttpSender l_sender = new HttpSender();
		l_response = (String) l_sender.sendPost("http://api.hackerrank.com/checker/submission.json",l_input_map, null);
		System.out.println("Response : "+l_response);
		
				
	}catch(Exception ex){
		System.out.println("Exception : "+ex);
	}

}

}

Note - : HttpSender is my own class for requesting to api โ€ฆThat class is already in use for other apiโ€™s and working fine. Please check my above code.
Please help me out this problem.

Thanks
Mayank Gupta

Join in the discussion - add comment below:

Login / Signup to post new comments