Creating API getter
Closed this issue · 2 comments
kination commented
Hello.
I'm trying to make API receiver via parallec, but seems I'm not doing in right way.
ParallelClient pc = new ParallelClient();
pc.prepareHttpGet("").setTargetHostsFromString("xxx.com/data?apikey=123456")
.execute(new ParallecResponseHandler() {
public void onCompleted(ResponseOnSingleTask res,
Map<String, Object> responseContext) {
System.out.println( "received: " + res.toString() + "\n"); }
});
In this case it is returning total html data instead of target data. It returns JSON data when I input xxx.com/data?apikey=123456
in browser.
Am I doing something wrong?
Thanks.
jeffpeiyt commented
@djKooks Thanks for trying it out again. :-)
the url needs to be put into the prepareHttpGet("/data?apikey=123456") .
. and setTargetHostsFromString
will be only with xxx.com
Here is one example: https://github.com/eBay/parallec/blob/master/src/test/java/io/parallec/core/main/http/ParallelClientHttpBasicMoreOptionsTest.java#L75
kination commented
@jeffpeiyt Thanks! It works well now.