Home Send POST request from webapi c# to onesignal url
Reply: 0

Send POST request from webapi c# to onesignal url

user1579 Published in April 26, 2018, 8:50 pm

I'm very new on this and I need some help. I'm trying to send a notification from my webapi to my app. To do this a need just send a post to the url("https://onesignal.com/api/v1/notifications") with some informations (Header from authorization and content-type). But when I send the post it takes a long and and I just get The operation timeout has been reached, no message errors that could help me. I tryed the code from onesignal's documentation from asp.net solutions but isn't worked for me. Anyone can help? Or just help how can I trace the error with my requisiton? After try the code from onesignal's documentation I decided use the following code(both codes had the same behavior):

using (var client = new HttpClient())
            var url = new Uri("https://onesignal.com/api/v1/notifications");
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "Rest ID");
            var obj = new
                app_id = "APP ID",
                contents = new { en = "English Message" },
                included_segments = new string[] { "All" }
            var json = JsonConvert.SerializeObject(obj);
            var content = new StringContent(json, Encoding.UTF8, "application/json");
            var response = await client.PostAsync(url, content);

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.319733 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO