Test the CRM service with custom code in d 365 fo Json
internal final class TECCRMFinalJob
{
/// <summary>
/// Class entry point. The system will call this method when a designated menu
/// is selected or when execution starts and this class is set as the startup class.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
/* Newtonsoft.Json.Linq.JTokenWriter writer;
Newtonsoft.Json.Linq.JObject jObject;
ClrObject clrObject;
System.Net.HttpWebResponse response;
CLRObject clrObj;
System.Exception ex;
System.IO.Stream requestStream;
System.IO.StreamWriter streamWriter;
System.IO.StreamReader streamRead;
System.Net.WebHeaderCollection httpHeader, httpHeaderRes;
System.Net.HttpWebRequest request;
Notes reqBodyStr, resBodyStr;
str token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtXYmthYTZxczh3c1RuQndpaU5ZT2hIYm5BdyIsImtpZCI6ImtXYmthYTZxczh3c1RuQndpaU5ZT2hIYm5BdyJ9.eyJhdWQiOiJodHRwczovL3N5bmRyb21lY3JtdWF0LmNybTguZHluYW1pY3MuY29tIiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvNWEyMjQzYmEtOTg2ZC00MTYwLTk5NTQtNzI0ZjRjNWMyNTg0LyIsImlhdCI6MTcwODU5MDg0NiwibmJmIjoxNzA4NTkwODQ2LCJleHAiOjE3MDg1OTQ3NDYsImFpbyI6IkUyVmdZSGd1WWJGSUlkRlY4ZmIxSS9NZS9TcllCUUE9IiwiYXBwaWQiOiIyYjcwMzVhZi1lNDIzLTRmMGMtYTI5OS1lMjJiYjBlOWNlYTkiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC81YTIyNDNiYS05ODZkLTQxNjAtOTk1NC03MjRmNGM1YzI1ODQvIiwib2lkIjoiNGVlYTFiYmQtNjc2Ni00ZDk0LWE0NjgtOTg0ZmE3ZDJmNjVlIiwicmgiOiIwLkFYSUF1a01pV20yWVlFR1pWSEpQVEZ3bGhBY0FBQUFBQUFBQXdBQUFBQUFBQUFEREFBQS4iLCJzdWIiOiI0ZWVhMWJiZC02NzY2LTRkOTQtYTQ2OC05ODRmYTdkMmY2NWUiLCJ0ZW5hbnRfcmVnaW9uX3Njb3BlIjoiQVMiLCJ0aWQiOiI1YTIyNDNiYS05ODZkLTQxNjAtOTk1NC03MjRmNGM1YzI1ODQiLCJ1dGkiOiJnR25aSVNCYnRFbUFVcC1UYlhrOUFBIiwidmVyIjoiMS4wIiwieG1zX2NhZSI6IjEifQ.CLFwOgGa4QQ_c51EIXRQPggI3C5RhR4ETe4d83ztG-YucMpefFhfPMDrBgqI-ptuuJ1gtRDQMzt7IVobxGuJnwI74DZ2UlPrw1YqRqVIDuGF-sxP_L__gFb4KT2s5J3Wb-nErPSTY08C4OFfNzDs4zxHAqwVNbjqXTBHubj_JoZiiLJYC0affo70OZM7zgQN89N8Id4DvWHp4mKE1rLYocm6v8u1asXefXAB-RaDWkAWT8M4B1W9EZCgLSvQOfKu2N4lDu_cbOU2UrXN1A2y5-0y2EpRu9m7xYIEM2lTlf6lzWzJtyO6sFfNE_KMUWdCcfCv9nTUJbQqZG3-KVUEgg";
// setting all header here
httpHeader = new System.Net.WebHeaderCollection();
httpHeader.Add("authorization", "Bearer " + token);
httpHeader.Add("prefer","return=representation");
try
{
new InteropPermission(InteropKind::ClrInterop).assert();
clrObj = System.Net.WebRequest::Create("https://syndromecrmuat.api.crm8.dynamics.com/api/data/v9.2/new_billings");
request = clrObj;
request.set_Headers(httpHeader);
request.set_Method('POST');
request.set_ContentType('application/json; charset=utf-8');
// request.set_prefer('return=representation');
requestStream = request.GetRequestStream();
streamWriter = new System.IO.StreamWriter(requestStream);
writer = new Newtonsoft.Json.Linq.JTokenWriter();
writer.WriteStartObject();
writer.WritePropertyName("new_serialno");
writer.WriteValue("FOC1808Vinay1");
writer.WriteEndObject();
clrObject = writer.get_Token();
jObject = clrObject;
reqBodyStr = jObject.ToString();
// Request
streamWriter.WriteAsync(reqBodyStr);
streamWriter.Flush();
streamWriter.Close();
//Response
new InteropPermission(InteropKind::DllInterop).assert();
response = request.GetResponse();
requestStream = response.GetResponseStream();
streamRead = new System.IO.StreamReader(requestStream);
resBodyStr = streamRead.ReadToEnd();
// if(response.StatusCode == 204)
// {
info(strFmt("%1",resBodyStr));//info("Record updated succefuuly");
// }
//info(strFmt("%1",resBodyStr));
}
catch
{
info("Error: " + CLRInterop::getLastException().ToString());
}*/
TECAxToCrmGeneration AxToCrmGeneration = new TECAxToCrmGeneration();
str returnjson = AxToCrmGeneration.insertSalesBillingCrm(5637149842);
//TECAxToCrmGeneration AxToCrmGeneration = new TECAxToCrmGeneration();
// str returnjson = AxToCrmGeneration.updateSalesBillingCrm(68719931230, "e4e716f2-38d2-ee11-904c-6045bde85ebe");
info(returnjson);
}
}
Comments
Post a Comment