1

I am trying to upload files using MULTIPART entity method.But it fails in error says that {"error": "file parameter value 'None' is invalid"}

My code is:

File file = new File("C:/Users/sst-06/Desktop/new.txt");

        service.signRequest(dropBoxToken, request); 

        HttpClient client = new DefaultHttpClient();         

        String url="https://api-content.dropbox.com/1/files/dropbox/test";

        System.out.println("URL "+url);

        HttpPost post   = new HttpPost(url);

        MultipartEntity entity = new MultipartEntity(  );
        FileBody fileBody= new FileBody( file,"application/x-unknown");
        entity.addPart( "file",fileBody);
        System.out.println(fileBody);

        for (String key : request.getHeaders().keySet()){
             post.setHeader(key, request.getHeaders().get(key));            

        }

        post.setEntity( entity );    

        String response = EntityUtils.toString( client.execute(post).getEntity(), "UTF-8" );  
        client.getConnectionManager().shutdown();
        System.out.println(response);

And my entity file contains all the parameters as mentioned.

--hkYO-pBlK0UQLXjtVKLrBkOSXz7mYe-8WBVBvAnX Content-Disposition: form-data; name="file"; filename="new.txt" Content-Type: application/x-unknown Content-Transfer-Encoding: binary

--File contents-- --hkYO-pBlK0UQLXjtVKLrBkOSXz7mYe-8WBVBvAnX--

I dont know where i felt with error.Please help.

Thanks in advance

2
  • Nobody having answer regards this question? Commented May 7, 2013 at 14:26
  • Any success with that? Commented Aug 22, 2018 at 7:55

1 Answer 1

2

Is there any reason why you want to use the web service directly? Will you consider using the DropBox Java SDK?

https://www.dropbox.com/static/developers/dropbox-java-sdk-1.5.3.zip

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.