samczsun / Skype4J

Skype API written in Java. Does not support P2P chats
Apache License 2.0
145 stars 48 forks source link

Problem of transferring file via Skype #157

Open tanhopham1990 opened 6 years ago

tanhopham1990 commented 6 years ago

Hi guys, I have a problem while running the code:

public static void sendSkypeFile(String username, String password, String identity, File file){ Skype skype = new SkypeBuilder(username, password).withAllResources().build(); try { skype.login(); Chat chat = skype.loadChat(identity); chat.sendFile(file); System.out.println("File sent!"); skype.logout(); } catch (ConnectionException e) { e.printStackTrace(); } }

The error throws: com.samczsun.skype4j.exceptions.ConnectionException: While uploading data (400 Bad Request) at com.samczsun.skype4j.internal.ExceptionHandler.generateException(ExceptionHandler.java:50) at com.samczsun.skype4j.internal.Endpoints$EndpointConnection.connect(Endpoints.java:372) at com.samczsun.skype4j.internal.Endpoints$EndpointConnection.connect(Endpoints.java:302) at com.samczsun.skype4j.internal.Endpoints$EndpointConnection.post(Endpoints.java:286) at com.samczsun.skype4j.internal.Utils.upload(Utils.java:69) at com.samczsun.skype4j.internal.chat.ChatImpl.sendFile(ChatImpl.java:145)

Please show me why and how to resolve it. I will appreciate all your helps! Thanks

metasonic commented 6 years ago

Try having a look over this https://github.com/OllieTerrance/SkPy/issues/82 Looks like you need to add an additional header to the request

iskrenyp commented 5 years ago

Hi, I am facing the same issue. Sending messages works, but not files. I am getting the same error as @tanhopham1990