无法通过 OKTA 创建用户 API

Cannot create user via OKTA API

我正在尝试使用 Okta 的 api 将用户添加到应用程序。这是我的要求:

POST /api/v1/apps/0oagjhAEEQZFXXLMFVSQ/users/00ugfzFQBXZJFRJCTAUX

Accept: application/json
Content-Type: application/json
Authorization: SSWS <apikey>

为什么会出现此错误?

{
    "errorCode": "E0000003",
    "errorSummary": "The request body was not well-formed: Could not read JSON: No content to map to Object due to end of input; nested exception is java.io.EOFException: No content to map to Object due to end of input",
    "errorLink": "E0000003",
    "errorId": "oaeqgZFFjUXS2qcagR7-PIBYA",
    "errorCauses": []
}

请求应该是一个 HTTP PUT 并且有一个空的 JSON 集合作为正文。

这是一个 curl 请求示例

$ curl -X PUT -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: SSWS ${OKTA_APIKEY}" -H "Cache-Control: no-cache" -d "{ }" ${OKTA_URL}/api/v1/apps/0oagjhAEEQZFXXLMFVSQ/users/00ugfzFQBXZJFRJCTAUX

请注意,此示例假定存在两个环境变量。如果你想自己 运行 这个 curl 命令,你必须先设置那些环境变量。这是一个如何执行此操作的示例,请确保将示例值替换为您的 Okta 实例的实际值。

$ export OKTA_URL="https://example.okta.com"
$ export OKTA_APIKEY="01abCdefghIjkLMNOPqRsTUVW2xYZabcD3456efGhi"

您还可以在消息正文中使用用户上下文对 /apps 资源执行 POST。

 curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: SSWS {{OKTA_APIKEY}" -H "Cache-Control: no-cache" -H "Postman-Token: 8e59ab19-81e7-2a54-4bd5-df2bbb564059" -d '{
          "id": "userId",
          "scope": "USER",
          "credentials": {
            "userName": "user@example.com"
          }
        }  ' {{OKTA_URL}}