here is my working code
val source = scala.io.Source.fromFile("D:/plugin.json").mkString
val httpclient = new DefaultHttpClient()
val httpPost = new HttpPost("http://ip:port/storage/hdfs1.json")
val reqEntity = new StringEntity(source)
httpPost.setEntity(reqEntity)
httpPost.setHeader("content-type", "application/json")
httpPost.setHeader("Accept", "application/json")
val response = httpclient.execute(httpPost)
println(response.getStatusLine().getStatusCode())
On Fri, Jul 10, 2015 at 7:15 PM, Jim Bates <[email protected]> wrote:
> Great!
>
> Can you post your working changes to close out this thread?
>
> On Fri, Jul 10, 2015 at 8:35 AM, Hafiz Mujadid <[email protected]>
> wrote:
>
> > thanks Jim! it worked :)
> >
> > On Fri, Jul 10, 2015 at 6:16 PM, Jim Bates <[email protected]> wrote:
> >
> > > I'm not sure what library you are using but I would start with changing
> > the
> > > way you are posting the request. I would not do it as a posted file in
> a
> > > multipart media posting. Pull the JSON data from the file and add it as
> > the
> > > message body of the post.
> > >
> > > On Fri, Jul 10, 2015 at 8:08 AM, Hafiz Mujadid <
> [email protected]
> > >
> > > wrote:
> > >
> > > > Hi Jim !
> > > >
> > > > I am also able to upload file using curl but issue is with java code.
> > > >
> > > > Can you tell me where all plugin files are stored on disk?
> > > >
> > > > Thanks
> > > >
> > > > On Fri, Jul 10, 2015 at 5:52 PM, Jim Bates <[email protected]>
> > wrote:
> > > >
> > > > > I would think it may be the multipart entry. I would just post the
> > json
> > > > > data as part of the body of the post message. Here is an example
> curl
> > > > that
> > > > > works.
> > > > >
> > > > > curl -X POST -H "Authorization: Basic bWFwcjpyb290NG1hcHI=" -H
> > > > > "Content-Type: application/json" -d
> > > > >
> > > > >
> > > >
> > >
> >
> '{"name":"nfl","config":{"type":"file","enabled":true,"connection":"maprfs:///","workspaces":{"views":{"location":"/mapr/
> > > > > demo.mapr.com/data/views
> > > > >
> > ","writable":true,"defaultInputFormat":null},"json":{"location":"/mapr/
> > > > > demo.mapr.com/data/nfl/json
> > > > >
> > >
> ","writable":false,"defaultInputFormat":"json"},"csv":{"location":"/mapr/
> > > > > demo.mapr.com/data/nfl/csv
> > > > >
> > >
> ","writable":false,"defaultInputFormat":"csv"},"tab":{"location":"/mapr/
> > > > > demo.mapr.com/data/nfl/txt
> > > > >
> > >
> ","writable":false,"defaultInputFormat":"tsv"},"xml":{"location":"/mapr/
> > > > > demo.mapr.com/data/nfl/xml
> > > > >
> > > > >
> > > >
> > >
> >
> ","writable":false,"defaultInputFormat":null}},"formats":{"csv":{"type":"text","extensions":["csv"],"delimiter":","},"tsv":{"type":"text","extensions":["tsv","txt"],"delimiter":"\t"},"json":{"type":"json"}}}}'
> > > > > http://maprdemo:8047/storage/nfl.json
> > > > >
> > > > > On Fri, Jul 10, 2015 at 7:41 AM, Hafiz Mujadid <
> > > [email protected]
> > > > >
> > > > > wrote:
> > > > >
> > > > > > Thanks jim!
> > > > > >
> > > > > > I am calling this rest api from java code but getting bad
> request.
> > My
> > > > > code
> > > > > > is written as in this stackoverflow question
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://stackoverflow.com/questions/31340731/java-api-to-add-storage-plugin-in-apache-drill
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Fri, Jul 10, 2015 at 5:31 PM, Jim Bates <[email protected]>
> > > > wrote:
> > > > > >
> > > > > > > Are you asking to configure a new storage plugin? Not sure
> abut a
> > > > > > specific
> > > > > > > java API process but you could easily use the REST API.
> > > > > > >
> > > > > > > POST /storage/my_stodrge_plugin.json HTTP/1.1
> > > > > > > Host: maprdemo:8047
> > > > > > > Content-Type: application/json
> > > > > > >
> > > > > > > {
> > > > > > > "name" : "my_plugin",
> > > > > > > "config" : {
> > > > > > > "type" : "file",
> > > > > > > "enabled" : false,
> > > > > > > "connection" : "maprfs:///",
> > > > > > > "workspaces" : null,
> > > > > > > "formats" : null
> > > > > > > }
> > > > > > > }
> > > > > > >
> > > > > > > On Fri, Jul 10, 2015 at 7:13 AM, Hafiz Mujadid <
> > > > > [email protected]
> > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > Hi all!
> > > > > > > >
> > > > > > > > Is there any way to add a new storage plugin using java api?
> > > > > > > >
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Regards: HAFIZ MUJADID
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Regards: HAFIZ MUJADID
> > > >
> > >
> >
> >
> >
> > --
> > Regards: HAFIZ MUJADID
> >
>
--
Regards: HAFIZ MUJADID