Esempio n. 1
0
        public async Task <string> PostWorkOrder()
        {
            var client = new HttpClient();

            client.BaseAddress = new Uri("http://127.0.0.1:8989/PostWorkOrderStub/1/0/Workorders");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var workOrderRequest = new WorkOrderRequest()
            {
                Code   = "Code008",
                Source = "ICOMS"
            };

            var content = new StringContent(
                JsonConvert.SerializeObject(workOrderRequest),
                Encoding.UTF8,
                "application/json");
            var response = await client.PostAsync("", content);

            if (response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadAsStringAsync());
            }
            return(string.Empty);
        }
Esempio n. 2
0
        public string PostWorkOrder()
        {
            var workOrderRequest = new WorkOrderRequest()
            {
                Code   = "Code008999900909i",
                Source = "ICOMS"
            };

            return(Post <string>(workOrderRequest, string.Empty));
        }