0

我正在尝试通过以下方式向我们的Sitecore9实例发出请求Postman

方法:

POST

网址:

https://{{sitecorehost}}/sitecore/api/ssc/auth/login

标题:

Content-Type:application/json

身体:

{
    "domain": "sitecore",
    "username": "{{sitecoreusername}}",
    "password": "{{sitecorepassword}}"
}

虽然我可以使用环境变量中提供的 URL轻松登录到实例,但在Postman此返回一个。403SitecorePostman

apikey站点管理员已向我提供了一个,但身份验证文档似乎没有指定应该如何使用它,或者我是否需要将它与身份验证值一起传递。

确实描述了使用 apikey的文档还描述了使用它的 GUID 检索项目,但是当我这样请求时Postman

方法:

GET

网址:

https://{{sitecorehost}}/sitecore/api/ssc/aggregate/content/Items('{5AB4C9A0-5889-4F50-9D7F-D960A1015FA7}')?sc_apikey={{sitecoreapikey}}

标题:

Content-Type:application/json

我得到的只是响应500 Internal Server Error中的一个:body

"message": "Object reference not set to an instance of an object.",
4

1 回答 1

1

Sitecore 中有不同类型的 API 密钥,对于 Sitecore 9.0,您需要从模板 /sitecore/templates/System/Services/OData 项目 API 密钥创建一个“ OData 项目 API 密钥”,而不是核心数据库中的“API 密钥”在 /sitecore/system/Settings/Services/API Keys/ 下面

此外,您需要在 API 密钥中填写数据库,您可以使用 value web 可能这是您的问题,如果您将其留空,则会收到错误“对象引用未设置为对象的实例”。在 Sitecore 9.0 中

对于 AllowedControllers,您可以使用 value *

对于使用 Postman 登录,登录后你会得到一个 cookie,你需要在你的 getitem 请求中使用它。您可以下载以下 Postman 工具导出文件作为示例。

于 2019-11-29T09:12:31.997 回答