0

我正在尝试使用 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": []
}
4

2 回答 2

1

请求应该是一个 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"
于 2015-01-09T19:31:06.913 回答
1

您还可以使用消息正文中的用户上下文对 /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}}
于 2015-04-29T18:52:06.580 回答