When I try to get the Json data from the response it does not work. I'm new to Json so I'm not sure how to go about this.
Here is the code I have atm:
//process ajax and make API call to active campaign
[HttpPost]
public ActionResult ProcessPreferences(string categoryTag, string userEmailAddr)
{
string applyToTag = categoryTag;
string emailAddr = userEmailAddr;
/*
* Active Campign API Integration
*/
// By default, this sample code is designed to get the result from your ActiveCampaign installation and print out the result
var acs = new Acs("api_key_removed", "api_url_removed");
Dictionary<string, string> getParameters = new Dictionary<string, string>();
getParameters.Add("api_action", "contact_view_email");
getParameters.Add("api_output", "json");
getParameters.Add("email", emailAddr);
var response = acs.SendRequest("GET", getParameters);
var obj = System.Web.Helpers.Json.Decode(response);
return Content(obj.tags);
}
}
Everything I find on google is not working. I tried this but it not work:
var obj = System.Web.Helpers.Json.Decode(response);
return Content(obj.tags);
I'm working with active campaign so might be a different method of getting json result, not sure.
Here is the data I want from the Json result.
I know the api call is working as I can write the Json data to browser console. return Content(response);
Then written with jquery.
The question has already been answered, but I think in a cumbersome way.
There is no point in converting the respnse to an object just for return it back to the same state (JSON).
you need return the reponse as it:
[HttpPost]
public ActionResult ProcessPreferences(string categoryTag, string userEmailAddr)
{
...
var response = acs.SendRequest("GET", getParameters);
return Content(response, "application/json");
}
Instead of ActionResult go for JsonResult. Try the below code:
public JsonResult ActionName()
{
your code goes here ....
return Json(outputobj);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.