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);
}