BExIS.Web.Shell.Controllers.UiTestController.CallGFBIOWebservice C# (CSharp) Method

CallGFBIOWebservice() public method

public CallGFBIOWebservice ( long id, string apiName, string entityName, string json ) : Task
id long
apiName string
entityName string
json string
return Task
        public async Task<string> CallGFBIOWebservice(long id, string apiName,string entityName, string json)
        {

            string server =
                @"http://gfbio-pub2.inf-bb.uni-jena.de:8080/api/jsonws/GFBioProject-portlet.";

            string jsonRequest = @"request-json";


            //string parameters = @"[{" + parametername + ":" + id + "}]";
            //"[{\""+parametername+"\":"+id+"}]";
            string parameters = json;

            string url = server+ entityName+"/"+ apiName + "/" + jsonRequest + "/";

            

            Debug.WriteLine(url);
            string returnValue = "";

            try
            {
                using (var client = new HttpClient())
                {
                    //generate url

                    client.BaseAddress = new Uri(url);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    //[email protected]:WSTest
                    var byteArray = Encoding.ASCII.GetBytes("[email protected]:AgentPhase2");

                    // "basic "+ Convert.ToBase64String(byteArray)
                    AuthenticationHeaderValue ahv = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
                    client.DefaultRequestHeaders.Authorization = ahv;

                    //http://gfbio-pub2.inf-bb.uni-jena.de:8080/api/jsonws/GFBioProject-portlet.researchobject/get-research-object-by-id/request-json/%5B%7B%22researchobjectid%22%3A3%20%7D%5D
                    string requesturl = url + Server.UrlEncode(parameters);
                    Debug.WriteLine(requesturl);
                    Debug.WriteLine(Server.UrlEncode(parameters));
                    HttpResponseMessage response = await client.GetAsync(requesturl);
                    response.EnsureSuccessStatusCode();
                    returnValue = ((HttpResponseMessage)response).Content.ReadAsStringAsync().Result;
                }
                return returnValue;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }