In this Article I will explain how to use the REST Generator (Response Content) within Workflow 7.6.
Other articles
7.6.4383.479 was the first build to have this
This should also pull in the headers and map those, I've yet to test this out.
Works perfect, I modified the code a bit as I had to create a POST with a JSON object containing "UserName" and "Password" to retrieve the the session token "X-Auth-Token" from the Response Header.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); request.ServicePoint.Expect100Continue = false; request.Method = "POST"; request.ContentType = "application/json"; using (var streamWriter = new StreamWriter(request.GetRequestStream())) { string json = "{" + "\"UserName\":\""+Username+"\","+"\"Password\":\""+Password+"\"}}"; streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); } using (WebResponse response = request.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetResponseStream())) { string sessionToken = response.Headers["X-Auth-Token"]; return sessionToken; } }
Many thanks for your help.
Untested but you should be able to do something like
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(newURL); request.Method = "GET"; request.ServicePoint.Expect100Continue = false; request.ContentType = "application/x-www-form-urlencoded"; using (WebResponse response = request.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetResponseStream())) { responseString = reader.ReadToEnd(); string limit = response.Headers["X-RateLimit-Limit"]; } }
Replace "X-RateLimit-Limit" with your Header string you need.
According to Symantec there is no possibilities to extract the Response Header with the REST Generator, so to do that I must use a script component. I will add this as a feature request/idea.
I will create a support case for this and I will keep you posted about their response.
Besides this I found another issue as this REST API is SSL encrypted and I have choosen to "Ignore Certificate Warnings" under Machine Settings - Remote Connections on the Workflow Server. With this enabled I don't get any warnings, and thats fine but I wont't get the correct status code result: 201 Created, instead I get 308 which indicates certificate problems. So I will raise a ticket for this as well.
Thanks, I appreciate all help I can get.
Hi,
I am struggling to get the REST Generator working for a "POST" where I am trying to create a session towards a REST API that will return the session token in the Response Header and not in the JSON response. I can get this to work when using Postman but I do not see how I could retrieve the "Response Header" data from the REST Generator. Anyone have any ideas on how to deal with this?
BR /// Per-Erik