在制作Repo请求时aikau中的401错误

时间:2016-12-12 06:35:21

标签: alfresco alfresco-share aikau

我试图用一个简单的例子来帮助下面的淬火。 could-anyone-provide-aikau-form-example-with-data-loading

基本上,我会在表单对话框加载时执行repo请求,并希望在对话框中显示文档libray noderef。所以我在对话框加载期间调用了 makeRepoRequest(),但是网络选项卡会抛出401错误。

请告诉我这个样品有什么问题?

/* studentForm.get.js */
function makeRepoRequest()
{
    var alfDestination = "something";


    var site = page.url.templateArgs.site;
    var result = remote.call("/slingshot/doclib/container/" + site + "/documentLibrary");
    return result.status.code;
    if (result.status.code == status.STATUS_OK) {
        alfDestination = JSON.parse(result).container.nodeRef;
    }
}

var formControls = [
  {
    name: "alfresco/forms/controls/TextBox",
    config: {
      name: "name1",
      label:"Name",
      placeHolder:"Enter Name Here",
      visibilityConfig: {
        initialValue: true
      }
    }
  },
  {
    name: "alfresco/forms/controls/TextBox",
    config: {
      label:"Age",
      name: "age",
      placeHolder:"Enter Age Here",
      visibilityConfig: {
        initialValue: true
      }
    }
  }
  ,
  {
    name: "alfresco/forms/controls/TextBox",
    config: {
      label:"NodeRef",
      name: "nodeRef",
      visibilityConfig: {
        initialValue: true
      },
      value : makeRepoRequest()
    }
  }
];

var showDialog = {
  name: "alfresco/buttons/AlfButton",

  config: {
    readOnly:"true",
    id:"dialog1",
    label: "Create New Student",
    additionalCssClasses: "call-to-action",
    publishTopic: "ALF_CREATE_FORM_DIALOG_REQUEST",
    publishPayloadType: "PROCESS",
    publishPayload: {
      dialogTitle: "Student Form",
      dialogConfirmationButtonTitle: "Register",
      dialogCancellationButtonTitle: "Cancel",
      formSubmissionTopic: "ALF_CRUD_CREATE",
      formSubmissionPayloadMixin: {
        url: "api/type/cm%3Astudent/formprocessor"
      },
      fixedWidth: true,
      widgets: formControls
    }
  }
};

model.jsonModel = {
widgets :[showDialog 
         ],
services : [
            "alfresco/dialogs/AlfDialogService",
            "alfresco/services/CrudService" 
        ]     
};

2 个答案:

答案 0 :(得分:1)

401状态代码表示用户未经过身份验证。你在哪里运行这段代码?是在Share还是独立的Aikau客户端?用户是否已登录?他们是否拥有访问该API的必要权限?他们是网站的成员吗?该网站有什么隐私?

答案 1 :(得分:0)

我已经测试了你的代码,并在alfreso sdk中静态地给出了我的站点名称(ex demo),它运行正常,并使用此代码给我nodeRef

function makeRepoRequest()
{
var alfDestination = "something";


var site = "demo";
var result = remote.call("/slingshot/doclib/container/" + site + "/documentLibrary");

if (result.status.code == status.STATUS_OK) {
    alfDestination = JSON.parse(result).container.nodeRef;
}
 return alfDestination ;
}

你测试过哪个网站名称是正确的吗?我已使用浏览器网址测试了此代码。