Newtonsoft.Json-for-Unity icon indicating copy to clipboard operation
Newtonsoft.Json-for-Unity copied to clipboard

No compilation errors but JSONSerialze generated data returns BadRequest status code in Android

Open apar945 opened this issue 2 years ago • 2 comments

Hello,

I have read through the documentation, tried AOT "preserve-all" method, reviewed many open/closed tickets. However, my unity application does not work when compiled with IL2CPP scripting backend. We use Json for exchange data via APIs running in an AWS backend. When compiled with Mono, they work fine. But Google Play requires Armv64 support in your build to be allowed to publish the app. So we compiled a version with IL2CPP and there were no compile time issues. However, the Newtonsoft.Json dependent code does not work properly. I have tried version 13.0.102 of the release.

What could I try to get this to work? Any suggestions would be appreciated.

Regards Ankit

apar945 avatar Mar 03 '22 03:03 apar945

Hello @apar945! Nice of you to have tried reading up, that is such a great start!

Could you possibly get the error logs from the android build? It can sometimes be tricky, but making a development build should be a good start. Then the errors should be shown on screen and on connected PC inside Unity I believe.

If you could also provide the C# code and class used to serialize or deserialize then that'd be awesome. :) So I know which edge cases you might be hitting on.

applejag avatar Mar 03 '22 04:03 applejag

Hello @jilleJr I was using a DLL which was referring to Newtonsoft.Json dll. I brought the code for the dll into the project and then tried serialising the data and calling the API and it all worked. So it seems like loading the json calls from another DLL, built in .Net targeting .Net Standard 2.0, was not working. I will now test all areas of the application which use this call to confirm if functionality is broken.

Update: I just checked that I have been testing with unity newtonsoft package 3.0.1 today so that has been working and I am sure your package would also work as the unity package is fork of it.

Regards Ankit

apar945 avatar Mar 07 '22 00:03 apar945