json call with C#
        Posted  
        
            by 
                Vaccano
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Vaccano
        
        
        
        Published on 2011-02-13T06:16:52Z
        Indexed on 
            2011/02/13
            7:25 UTC
        
        
        Read the original article
        Hit count: 207
        
I am trying to make a json call using C#. I made a stab at creating a call, but it did not work:
public bool SendAnSMSMessage(string message)
{
    HttpWebRequest request = (HttpWebRequest)
                             WebRequest.Create("http://api.pennysms.com/jsonrpc");
    request.Method = "POST";
    request.ContentType = "application/json";
    string json = "{ \"method\": \"send\", "+
                  "  \"params\": [ "+
                  "             \"IPutAGuidHere\", "+
                  "             \"[email protected]\", "+
                  "             \"MyTenDigitNumberWasHere\", "+
                  "             \""+message+"\" " +
                  "             ] "+
                  "}";
    StreamWriter writer = new StreamWriter(request.GetRequestStream());
    writer.Write(json);
    writer.Close();
    return true;
}
Any advice on how to make this work would be appreciated.
© Stack Overflow or respective owner