Hafiz

Please try using the following if it fetches.

"http://localhost:6080/service/public/api/repository<http://localhost:6080/service/public/api/repository/1>?type=hdfs"

For a quicker check you can use curl calls.

curl -i -X GET --header "Accept:application/json" -H "Content-Type: 
application/json" -u admin:admin 
http://localhost:6080/service/public/api/repository?type=hdfs

Also let me know the name of  service/ repository which you created and which 
you are querying to download.

Try this and let me know.

Regards,
Ramesh

From: Hafiz Mujadid <[email protected]<mailto:[email protected]>>
Reply-To: 
"[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Saturday, August 8, 2015 at 10:18 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: issue with rest api

Hi

I am trying to use rest api's in my java/scala code

here is my code
 val httpclient = new DefaultHttpClient()
    val auth = new AuthScope(host, AuthScope.ANY_PORT)
    val credentials = new UsernamePasswordCredentials("admin", "admin")
    httpclient.getCredentialsProvider()
      .setCredentials(auth, credentials)
    val httpget = new 
HttpGet("http://localhost:6080/service/public/api/repository/1";)
    httpget.setHeader("Accept", "application/xml")
    val response = httpclient.execute(httpget)
    val entity = response.getEntity
    if (entity != null) {
      val in = new BufferedReader(new InputStreamReader(entity.getContent()))
      var line = in.readLine()
      var response = new StringBuffer()
      while (line != null) {
        response.append(line + "/n")
        line = in.readLine()
      }
      in.close()
      println(response.toString())
    }


But it is not returning repository details



any suggestion how can i use rest services in my java application?

Thanks

Reply via email to