Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload media not work #5

Closed
pcomp96 opened this issue May 4, 2023 · 1 comment
Closed

Upload media not work #5

pcomp96 opened this issue May 4, 2023 · 1 comment

Comments

@pcomp96
Copy link

pcomp96 commented May 4, 2023

Hi @harmonyzhang,
First of all, thank you for this repository, is very useful.


I implemented everything easily and now I'm doing the testing phase, a week ago I launched the tests for the uploadMedia and it worked. Today launching a test with the average upload, it failed.
The exception thrown comes from the library

java.lang.NoSuchMethodError: okhttp3.MultipartBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody; at com.whatsapp.api.impl.WhatsappBusinessCloudApi.uploadMedia([WhatsappBusinessCloudApi.java:73]

Go to WhatsappBusinessCloudApi.uploadMedia

  public UploadResponse uploadMedia(String phoneNumberId, String fileName, FileType fileType, byte[] file) {

        RequestBody requestFile = MultipartBody.create(file, MediaType.parse(fileType.getType()));

           .......
    }

From the source code I see that there is no method with this signature:
MultipartBody.create(byte[] file, MediaType fileType);


There is a method that has this signature and I think you need to change this line so as not to throw this exception.

code

For the solution I think it would be enough just to reverse the parameters passed to the method.

I hope you find this observation useful, I remain available for clarification .. Thank you! 😉

harmonyzhang added a commit that referenced this issue May 5, 2023
Fix the problem
Upload media not work #5
@harmonyzhang
Copy link
Owner

harmonyzhang commented May 5, 2023

Thanks for your feedback, the issue has been fixed in v1.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants