public HttpResponseMessage Notify(string message, int stickerPackageId, int stickerId) { LineSticker sticker = new LineSticker { StickerPackageId = stickerPackageId, StickerId = stickerId }; return(Notify(message, sticker)); }
private HttpResponseMessage Request(string endpoint, string message) { byte[] _imageFile = null; LineSticker sticker = new LineSticker { StickerPackageId = 0, StickerId = 0 }; return(Request(endpoint, message, _imageFile, sticker)); }
private HttpResponseMessage Request(string endpoint, string message, byte[] imageFile, LineSticker sticker) { string _endpoint = $"https://notify-api.line.me/api/{endpoint}"; using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Add("Authorization", $"Bearer {this.Token}"); if (endpoint.Equals("status")) { MediaTypeWithQualityHeaderValue contentType = new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"); client.DefaultRequestHeaders.Accept.Add(contentType); } //StringContent contentData = new StringContent(message, Encoding.UTF8, "application/x-www-form-urlencoded"); FormUrlEncodedContent contentData = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("", "login") }); var requestContent = new MultipartFormDataContent(); // here you can specify boundary if you need---^ var imageContent = new ByteArrayContent(imageFile); imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/jpeg"); requestContent.Add(imageContent, "imageFile", "image.jpg"); return(endpoint.Equals("status") ? client.GetAsync(_endpoint).Result : client.PostAsync(_endpoint, contentData).Result); } }
public HttpResponseMessage Notify(string message, LineSticker sticker) { byte[] _imageFile = null; return(Request("notify", message, _imageFile, sticker)); }