i am trying to insert record in zoho creator using C#.
When i run this program, new record gets inserted but the field value shows blank.
For eg. i am inserting new department using below code, in department report i can see that new row gets added but value of department name is blank.
class ZohoCreaterAPI
{
public static string zohourl = "https://creator.zoho.com/api/XXXX/json/";
public static void Main(string[] args)
{
string result = APIMethod();
System.Console.Write(result);
}
public static String APIMethod()
{
string url = zohourl + "testapp2/form/FormA/record/add"+ "?";
string postContent = "scope=creatorapi";
postContent = postContent + "&authtoken=XXXXXXXXXX";//Actual authtoken entered here
StringBuilder xmlStr = new StringBuilder();
Dictionary<string, string> DepartmentList = new Dictionary<string, string>();
DepartmentList.Add("Department", "Test");
string JsonString = (new JavaScriptSerializer()).Serialize(DepartmentList);
// For Json
postContent = postContent + "&jsonString=" + JsonString;
string result = AccessCreator(url, postContent);
return result;
}
public static string AccessCreator(string url, string postcontent)
{
WebRequest request = WebRequest.Create(url);
request.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(postcontent.ToString());
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
return responseFromServer;
}
}