public ActionResult Create(string clickwrapId) { // Obtain your OAuth token var accessToken = RequestItemsService.User.AccessToken; var basePath = $"{RequestItemsService.Session.BasePath}/clickapi"; // Base API path try { var accountId = RequestItemsService.Session.AccountId; // Call the Click API to get a clickwrap agreements var clickWrapAgreements = GetClickwrapResponses.GetAgreements(clickwrapId, basePath, accessToken, accountId); // Show results ViewBag.h1 = "Get clickwrap responses"; ViewBag.message = $"Results from the ClickWraps::getClickwrapAgreements method:"; ViewBag.Locals.Json = JsonConvert.SerializeObject(clickWrapAgreements, Formatting.Indented); return(View("example_done")); } catch (ApiException apiException) { ViewBag.errorCode = apiException.ErrorCode; ViewBag.errorMessage = apiException.Message; return(View("Error")); } }
public ActionResult Create() { // Obtain your OAuth token var accessToken = RequestItemsService.User.AccessToken; var basePath = $"{RequestItemsService.Session.BasePath}/clickapi"; // Base API path try { if (string.IsNullOrEmpty(RequestItemsService.ClickwrapId)) { ViewBag.errorCode = 400; ViewBag.errorMessage = "Cannot find any clickwrap. Please first create a clickwrap using the first example."; return(View("Error")); } var accountId = RequestItemsService.Session.AccountId; var clickwrapId = RequestItemsService.ClickwrapId; // Call the Click API to get a clickwrap agreements var clickWrapAgreements = GetClickwrapResponses.GetAgreements(clickwrapId, basePath, accessToken, accountId); // Show results ViewBag.h1 = "The data was successfully fetched"; ViewBag.message = $"The clickwrap contains {clickWrapAgreements.UserAgreements.Count} agreements."; ViewBag.Locals.Json = JsonConvert.SerializeObject(clickWrapAgreements, Formatting.Indented); return(View("example_done")); } catch (ApiException apiException) { ViewBag.errorCode = apiException.ErrorCode; ViewBag.errorMessage = apiException.Message; return(View("Error")); } }