Start a new topic

Error 401 Unauthorized using Portal via Api


i want to open portal via api using single sign on, but i always get the error "401 Unauthorized" when calling in javascript. The exact request that fails is:

POST https://<sitename>

When doing this, the portal opens and a screen "Token has expired." shows up.

What am i doing wrong? Thanks.      

$(document).ready(function () {
        site: "<sitename>"

function openChargebeePortal() { //called on click
    var chargebeeInstance = Chargebee.getInstance();
    chargebeeInstance.setPortalSession(function () {

        return new Promise(function (resolve, reject) {
                url: 'CreatePortalSession',
                method: 'POST',
                data: '{"customerId":"<costumerid>"}',
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                success: function (msg) {

    var cbPortal = chargebeeInstance.createChargebeePortal();{


//Server code    
public JsonResult CreatePortalSession(string customerId) {
      ApiConfig.Configure(<sitename>, <api-key>);
      EntityResult result = PortalSession.Create()
      return Json(result.PortalSession);


Login or Signup to post a comment