using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
public static void Main()
Console.WriteLine(GetToken());
string token = GetToken2().Result;
Console.WriteLine(token);
string ncObject = "[ { \"name\": \"Fellowship\", \"ncContentTypeAlias\": \"ProviderEducation\", \"educationType\": [\"Fellowship\"], \"schoolName\": \"The University of Oklahoma Health Sciences Center\", \"year\": null, \"focus\": \"Pediatrics, Neonatal - Perinatal Medicine\", \"key\": \"8247d207-e928-4e33-ab77-be8ad071519c\" }, { \"name\": \"Residency\", \"ncContentTypeAlias\": \"ProviderEducation\", \"educationType\": \"Residency\", \"schoolName\": \"The Tamil Nadu Dr. M.G.R. Medical University\", \"year\": null, \"focus\": \"Pediatrics\", \"key\": \"5db49149-0a37-4a48-86c1-f0160618cecf\" }, { \"name\": \"Residency\", \"ncContentTypeAlias\": \"ProviderEducation\", \"educationType\": \"Residency\", \"schoolName\": \"Albert Einstein Medical Center\", \"year\": null, \"focus\": \"Pediatrics\", \"key\": \"5b579fca-0973-471d-a6c5-e01b2f4ccfae\" }, { \"name\": \"Medical School\", \"ncContentTypeAlias\": \"ProviderEducation\", \"educationType\": \"Medical School\", \"schoolName\": \"Coimbatore Medical College\", \"year\": null, \"focus\": null, \"key\": \"6a85969d-0f14-416c-a06e-eaf6b541cf37\" } ]";
JArray ncJArray = JArray.Parse(ncObject);
foreach(var item in ncJArray)
var testStr = JArray.Parse(item["educationType"].ToString());
item["educationType"] = JToken.Parse("[\"" + item["educationType"].ToString() + "\"]");
string backToDb = JsonConvert.SerializeObject(ncJArray);
Console.WriteLine(backToDb);
public static string GetToken()
string custId = "1263602";
string password = "BeldUch7";
string tokenUrl = "https://vault.trustcommerce.com/trustee/token.php";
var postData = $"custid={custId}&password={password}";
var data = Encoding.ASCII.GetBytes(postData);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(tokenUrl);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = data.Length;
using (var stream = webRequest.GetRequestStream())
stream.Write(data, 0, data.Length);
using (WebResponse wr = webRequest.GetResponse())
using (StreamReader rd = new StreamReader(wr.GetResponseStream()))
tokenResult = rd.ReadToEnd();
public static async Task<string> GetToken2()
using (var client = new HttpClient())
client.BaseAddress = new Uri("https://vault.trustcommerce.com");
var content = new FormUrlEncodedContent(new[]
new KeyValuePair<string, string>("custid", "1263602"),
new KeyValuePair<string, string>("password", "BeldUch7")
var result = await client.PostAsync("/trustee/token.php", content);
token = result.Content.ReadAsStringAsync().Result;