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

Send POST request from webapi c# to onesignal url

gustavo borges
1#
gustavo borges Published in 2017-12-07 18:09:46Z

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.Clear();
            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.297665 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO