Monday, 13 January 2020

Call Azure function from C# code






 string azureFunctionUrl = "";
            var content = new StringContent(jsonObjectString, Encoding.UTF8, "application/json");
            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("x-functions-key", "y3cQDQDJaPuZ6BH8G2aS4XoKo1c0ik0KjirVwU4REHvSBcFqWVTQrg==");
                client.DefaultRequestHeaders.Add("Accept", "application/json");
                //client.DefaultRequestHeaders.Add("Content-Type", "application/json; charset=utf-8");
                using (HttpResponseMessage response = client.PostAsync(azureFunctionUrl, content).Result)
                using (HttpContent respContent = response.Content)
                {
                    // ... Read the response as a string.
                    var tr = respContent.ReadAsStringAsync().Result;
                    // ... deserialize the response, we know it has a 'result' field
                    //dynamic azureResponse = JsonConvert.DeserializeObject(tr);
                    //// ... read the data we want
                    //result = azureResponse.result;
                }
            }

No comments:

Post a Comment

Read only field , get latest value from read only field in in power app portal

Below line is used to make field readonly in power app portal through js $( "#bdo_relationshiprole_name" ).parent().css( "po...