HttpPost Support for "application/octet" stream

I am working on a driver for the Rain Bird sprinkler. It expects to receive an encrypted payload via an http post.

I attempted the following

httpPost([
uri: "http://$SprinklerIP/stick",
headers: [
"Accept-Language": "en",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "RainBird/2.0 CFNetwork/811.5.4 Darwin/16.7.0",
"Accept": "/",
"Connection": "keep-alive",
"Content-Type": "application/octet-stream"
],
body: send_data
]) { response2 ->

It fails with the error groovy.lang.MissingMethodException: No signature of method: groovyx.net.http.EncoderRegistry.encodeForm() is applicable for argument types: ([B, java.lang.String)

If I send a string instead it succeeds but of course is rejected by the endpoint since it is expecting a different format. Any thoughts - is sending a byte array this way supported?

Try using the requestContentType setting of httpPost

didnt seem to make a difference. It looks like the outbound call is chocking on the byte array so it never even sends it

Ended up I had a different error in my encryption routine. Once I fixed this your suggestion did the trick. thanks!

1 Like