Please help me, I have a problem to push notification for android from ASP.NET webservice (VB.NET).
this is my code.
Public sApplicationID As String = "YYY....ZZZ"
Public sSENDER_ID As String = "222...555"

<WebMethod()> _
Public Function SendMessage(ByVal RegistrationID As String, ByVal Message As String) As String
    Dim regid As String = RegistrationID
    Dim tRequest As WebRequest
    tRequest = WebRequest.Create("")
    tRequest.Method = "post"
    'tRequest.ContentType = " application/json"
    tRequest.ContentType = " application/x-www-form-urlencoded"
    tRequest.Headers.Add(String.Format("Authorization: key={0}", sApplicationID))

    tRequest.Headers.Add(String.Format("Sender: id={0}", sSENDER_ID))

    Dim postData As String = "{""collapse_key"":""score_update"",""time_to_live"":108,""delay_while_idle"":1,""data"":{""message"":""" & Convert.ToString(Message) & """,""time"":""" & System.DateTime.Now.ToString() & """},""registration_ids"":" & regid & "}"
    Dim byteArray As [Byte]() = Encoding.UTF8.GetBytes(postData)
    tRequest.ContentLength = byteArray.Length

    Dim dataStream As Stream = tRequest.GetRequestStream()
    dataStream.Write(byteArray, 0, byteArray.Length)

    Dim tResponse As WebResponse = tRequest.GetResponse()

    dataStream = tResponse.GetResponseStream()

    Dim tReader As New StreamReader(dataStream)

    Dim sResponseFromServer As [String] = tReader.ReadToEnd()


    Return sResponseFromServer
End Function
Name:  s.png
Views: 697
Size:  4.6 KB

I was testing this service but I always getting error message

System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()

Please help me..