Empty request body in Android CloudSDK ParticleDevice.callFunction() execution

photon
Tags: #<Tag:0x00007fe21bc4ea00>

#1

Hello folks,

I’m using the Android CloudSDK library (https://github.com/particle-iot/particle-android/tree/master/cloudsdk - rev 0.5.1) and seeing an issue.

I’m making the call:

io.particle.android.sdk.cloud.ParticleDevice.callFunction(“updateState”, listOf(“test”)), but the resulting okhttp request seems to be lacking a request body, instead of containing the expected “test” content:

(extracted using Charles proxy)

:method: POST
:path: /v1/devices/3c0033000f47353136383631/updateState
:authority: api.particle.io
:scheme: https
authorization: Bearer XXXXX
content-type: application/json; charset=UTF-8
content-length: 2
accept-encoding: gzip
user-agent: okhttp/2.7.5

{}

Using the serial debugger on the target device, I confirm that the function ‘updateState’ is indeed being called with an empty argument.

Has anyone else seen this?

I should also note that this has worked for over a year, but I only recently came back to this project and noticed these calls were failing… I’m willing to accept it’s my fault somewhere :slight_smile: I just can’t figure out why the rendered http request is stripping out the body.

(p.s. Particle is awesome and all of these tools are awesome. This is the first time I’ve had to post something in years :slight_smile: )


#2

Hi there!

Thanks for the kind words about our tools! :slightly_smiling_face: :raised_hands:

I just tried this myself using those same arguments, and everything worked exactly as it should, complete with the expected HTTP body of {"params":"test"}. Would you be able to link to the source of your project somewhere? If not, can you reproduce this same issue with a “Hello, World”-sized test project?

By the way, here’s an extra tip for troubleshooting this stuff: CharlesProxy is great, but if you just want HTTP logs from the Cloud SDK, all you have to do is add this as a string resource in your app: <string name="http_log_level">FULL</string>. This will log all of your HTTP interactions to logcat, so you can just view them directly in Android Studio.