//Prog de test public string Lance() { //Déclare une nouvelle requete ReqAPI ReqContact = new ReqAPI(); try { //Ouvre la connexion Task.WaitAll(Task.Run(async() => await RunAsync(ReqContact))); } catch (System.Exception ex) { Err.DisplayException(ex); } finally { if (Co.GetHTTPClient() != null) { Co.Déconnecte(); } } Console.WriteLine(Contacts.GetPerson[0].m_firstname); Console.WriteLine(Contacts.GetPerson[1].m_firstname); Console.WriteLine(Contacts.GetPerson[2].m_firstname); Console.ReadKey(); return(Contacts.GetPerson[0].m_firstname); }
//Récup les contacts public async Task <ListContact> GetContact(ConnectionCRM Co) { // Requete des 3 premiers contacts RetrieveGetRequest = new HttpRequestMessage(HttpMethod.Get, Co.getVersionAPI() + "contacts?$top=3"); // Attend la reception RetrieveGetReponse = await Co.GetHTTPClient().SendAsync(RetrieveGetRequest); if (RetrieveGetReponse.IsSuccessStatusCode) // if 200, successfully { //Translate a Content of Request Response to Json Object JObject ReponseContacts = JsonConvert.DeserializeObject <JObject>(await RetrieveGetReponse.Content.ReadAsStringAsync()); // Store values choise in ListContact with JsonProperty in a member value of contacts ListContact result = JsonConvert.DeserializeObject <ListContact>(ReponseContacts.ToString()); //Retourne la liste return(result); } else { Console.WriteLine("Echec Récup Contact : {0}", RetrieveGetReponse.ReasonPhrase); throw new CrmHttpResponseException(RetrieveGetReponse.Content); } }
//Test SSIS public string Lance() { //Déclare une nouvelle requete ReqAPI ReqContact = new ReqAPI(); try { //Ouvre la connexion httpClient = Co.GetHTTPClient(); Task.WaitAll(Task.Run(async() => await RunAsync(ReqContact))); } catch (System.Exception ex) { Err.DisplayException(ex); } finally { if (httpClient != null) { httpClient.Dispose(); } } return(Contacts.GetPerson[0].m_firstname); }