httpPut issue

I need some assistance:
I need to send data to a pain in the ass API: That rest service requires the following format: "away":"away" < with the quotes and ‘:’ as well.
If I use the advanced rest client and send this exact string it works great, but i’m having a hard time with the httpPut

def data = "\"${obj}":"objVal\"" def params = [ uri: "${uri}/${objType}/${typeId}", path: "/", query: [ "auth": state?.authToken ], body: data ] log.debug "params: ${params}" httpPut(params) { resp ->

I have a C# program that I wrote to do this a couple years ago, but i’m having a hard time translating.
request.Method = “PUT”;
request.MaximumAutomaticRedirections = 4;
request.AllowAutoRedirect = true;
request.UseDefaultCredentials = true;
request.ContentType = “application/json”;

  var bytes = Encoding.Default.GetBytes(data);
                    request.ContentLength = bytes.Length;

                    using (var writeStream = request.GetRequestStream())
                    {
                        writeStream.Write(bytes, 0, bytes.Length);
                    }

Would the httpPutJson method work for your scenario?

I haven’t played with it, so not sure, but documentation says it should encode the data into the content type. That method should handle setting your request content type to application/json for you.

Take a look at the sendcommand function in my tado cooling device type. Specifically with how I send define the body in json. Works well with nested json also. Does this help you?

https://github.com/fuzzysb/SmartThings/blob/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/tado-cooling-ac.groovy