예제 #1
0
        public async Task <string> UpdateDevice(DevicesPostDto device)
        {
            var request = ConstructRequestMessage("PUT", "https://api.spotify.com/v1/me/player");

            request.Content = new StringContent(JsonConvert.SerializeObject(new { device_ids = new List <string> {
                                                                                      device.Device_Id
                                                                                  }, play = device.Play }));
            //    new FormUrlEncodedContent(new[]
            //{
            //    new KeyValuePair<string, string> ("device_ids", $"[{device.Device_Ids}]"),
            //    new KeyValuePair<string, string> ("play", device.Play.ToString())
            //});
            var response = await _client.SendAsync(request);

            var content = await response.Content.ReadAsStringAsync();

            return(content);
        }
예제 #2
0
        public async Task <IHttpActionResult> Put([FromBody] DevicesPostDto device)
        {
            var response = await _api.UpdateDevice(device);

            return(Ok(response));
        }