[Progress Communities] [Progress OpenEdge ABL] Forum Post: How to Post json data to MVC controller

  • Thread starter laura@refactoredmedia.com
  • Start date
Status
Not open for further replies.
L

laura@refactoredmedia.com

Guest
I have 2 javascript methods. One is a get method, and the other is a post. I was able to get data using the get method. But I cant retrieve the data from the post my get method js return fetch(sf_appPath +'ajax/getpublickey', { method: 'get', headers: { 'Content-Type': 'application/json' } }) .then(function (response) { return response.json(); }) Controller [HttpGet, Route("ajax/getpublickey")] public JsonResult PublicKey() { return "key"; } but havent been able to figure out how to get the data from the post. My javascript return fetch(sf_appPath + 'ajax/create-customer/', { method: 'post', headers: { 'Content-Type': 'application/json; charset=utf-8' }, data: { Email: cardholderEmail, PlanId: PlanId } }) .then(response => { return response.json(); }) My controller [HttpPost, Route("ajax/create-customer/")] public JsonResult CreateCustomer(string email, string planid) { string s = "test"; return Json(s); } email and plan ID are always null. Any suggestions?

Continue reading...
 
Status
Not open for further replies.
Top