public async Task <IActionResult> Ocelot()
        {
            var url = "http://apigw/shopping/api/v1/basket/items";

            var payload = new TestPayload()
            {
                CatalogItemId = 1,
                Quantity      = 1,
                BasketId      = _appUserParser.Parse(User).Id
            };

            var content = new StringContent(JsonConvert.SerializeObject(payload), System.Text.Encoding.UTF8, "application/json");


            var response = await _client.CreateClient(nameof(IBasketService))
                           .PostAsync(url, content);

            if (response.IsSuccessStatusCode)
            {
                var str = await response.Content.ReadAsStringAsync();

                return(Ok(str));
            }
            else
            {
                return(Ok(new { response.StatusCode, response.ReasonPhrase }));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Ocelot()
        {
            var url     = "http://apigw/shopping/api/v1/basket/items";
            var payload = new TestPayload()
            {
                CatalogItemId = 1,
                Quantity      = 1,
                BasketId      = _appUserParser.Parse(User).Id
            };
            var token = await HttpContext.GetTokenAsync("access_token");

            var response = await _client.PostAsync <TestPayload>(url, payload, token);

            if (response.IsSuccessStatusCode)
            {
                var str = await response.Content.ReadAsStringAsync();

                return(Ok(str));
            }
            else
            {
                return(Ok(new { response.StatusCode, response.ReasonPhrase }));
            }
        }