Click here to Skip to main content
15,900,616 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have received this code from a company we are using to send sms's but their support is really slow and was wondering if someone could assist me plz. Im getting several errors in the last part from Post.

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {

        public static byte[] Post(string uri, NameValueCollection pairs)
        {
            byte[] response = null;
            using (WebClient client = new WebClient())
            {
                response = client.UploadValues(uri, pairs);
            }
            return response;
        }
        String yourXml = "<?xml version='1.0' encoding='UTF-8'?>" +
                            "<gviSmsMessage>" +
                            "<affiliateCode>MYCODE</affiliateCode>" +
                            "<authenticationCode>MYAUTHCODE</authenticationCode>" +
                            "<submitDateTime>2015-01-21T15:29:39</submitDateTime>" +
                            "<messageType>text</messageType>" +
                            "<recipientList>" +
                            "<message>This is a test</message>" +
                            "<recipient>" +
                            "<msisdn>MYNUMBER</msisdn>" +
                            "</recipient>" +
                            "</recipientList>" +
                            "</gviSmsMessage>";

Post("http://www.gvi.bms.vine.co.za/httpInputhandler/ApplinkUpload", new NameValueCollection()
        {
            { "xml", yourXml }
        }
    }
}
Posted
Comments
Sergey Alexandrovich Kryukov 22-Jan-15 2:47am    
"Some errors"? Are you sure you are at right forum?
—SA
Ivan Lubbe 22-Jan-15 2:59am    
Sorry Sergey I would not usually do a post like this but I am pressed for time and need assistance.
Sergey Alexandrovich Kryukov 22-Jan-15 3:26am    
Nothing to sorry about. If you under pressure and spend time on something useless, it can be even worse. Why not spending time and explaining your problem properly?
-SA
nagendrathecoder 22-Jan-15 2:51am    
And what are those errors?
Ivan Lubbe 22-Jan-15 2:57am    
Error CS1520 Method must have a return type ConsoleApplication6 Program.cs 35
Error CS1002 ; expected ConsoleApplication6 Program.cs 37
Error CS1520 Method must have a return type ConsoleApplication6 Program.cs 37
Warning CS0109 The member 'Program.NameValueCollection()' does not hide an inherited member. The new keyword is not required. ConsoleApplication6 Program.cs 37
Error CS1002 ; expected ConsoleApplication6 Program.cs 38
Error CS1513 } expected ConsoleApplication6 Program.cs 38
Error CS1002 ; expected ConsoleApplication6 Program.cs 38

if you need to test your post method, do it in Main() method as below and also method call sysntax is
C#
MethodName(param1, param2);

you have missed last ) and ;
C#
static void Main() 
{
         Post("http://www.gvi.bms.vine.co.za/httpInputhandler/ApplinkUpload", 
           new NameValueCollection()
             {
                  { "xml", yourXml }
            });
    
}
 
Share this answer
 
C#
class Program
    {

        public static byte[] Post(string uri, NameValueCollection pairs)
        {
            byte[] response = null;
            using (WebClient client = new WebClient())
            {
                response = client.UploadValues(uri, pairs);
            }
            return response;
        }

        static void Main(string[] args)
        {
<pre>String yourXml = "<?xml version='1.0' encoding='UTF-8'?>" +
                            "<gviSmsMessage>" +
                            "<affiliateCode>MYCODE</affiliateCode>" +
                            "<authenticationCode>MYAUTHCODE</authenticationCode>" +
                            "<submitDateTime>2015-01-21T15:29:39</submitDateTime>" +
                            "<messageType>text</messageType>" +
                            "<recipientList>" +
                            "<message>This is a test</message>" +
                            "<recipient>" +
                            "<msisdn>MYNUMBER</msisdn>" +
                            "</recipient>" +
                            "</recipientList>" +
                            "</gviSmsMessage>";
 
Post("http://www.gvi.bms.vine.co.za/httpInputhandler/ApplinkUpload", new NameValueCollection()
        {
            { "xml", yourXml }
        }

}
}


Hope that helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900