Hi Ramesh

thanks for your response. I got the solution. here is my working code


val httpclient = new DefaultHttpClient()
    val httpget = new HttpGet(repo_url + "/" + id)
    httpget.addHeader(BasicScheme.authenticate(
      new UsernamePasswordCredentials(username, password),
      "UTF-8", false))
    httpget.setHeader("Accept", "application/json")
    val response = httpclient.execute(httpget)
    EntityUtils.toString(response.getEntity())


But I am failing in how to create a repository using rest api. is there any
java code example?

thanks

On Sun, Aug 9, 2015 at 12:40 AM, Ramesh Mani <[email protected]> wrote:

> 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]>
> Reply-To: "[email protected]" <
> [email protected]>
> Date: Saturday, August 8, 2015 at 10:18 AM
> To: "[email protected]" <[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
>



-- 
Regards: HAFIZ MUJADID

Reply via email to