From e0e07bbacbc0b586ff581bd51e16d0ff228f9c13 Mon Sep 17 00:00:00 2001 From: Benedikt Heinrichs <Heinrichs@itc.rwth-aachen.de> Date: Tue, 5 Mar 2019 11:02:54 +0100 Subject: [PATCH] Add Nomad Job Updater --- ConfigurationUpdater/Nomad.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ConfigurationUpdater/Nomad.cs b/ConfigurationUpdater/Nomad.cs index beaf850..2f912ea 100644 --- a/ConfigurationUpdater/Nomad.cs +++ b/ConfigurationUpdater/Nomad.cs @@ -14,15 +14,25 @@ namespace ConfigurationUpdater public static string UpdateJob(string jobId) { + string jobUrl = "http://localhost:4646/v1/job/" + jobId; - string postUrl = "http://localhost:4646/v1/job/" + jobId; - var httpWebRequest = (HttpWebRequest)WebRequest.Create(postUrl); + var request = (HttpWebRequest)WebRequest.Create(jobUrl); + + var response = (HttpWebResponse)request.GetResponse(); + + var jobString = ""; + using (var streamReader = new StreamReader(response.GetResponseStream())) + { + jobString = streamReader.ReadToEnd(); + } + + var httpWebRequest = (HttpWebRequest)WebRequest.Create(jobUrl); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { - string json = "{\"Job\": {}}"; + string json = "{\"Job\":" + jobString + "}"; streamWriter.Write(json); streamWriter.Flush(); -- GitLab