0

I'm trying to add a user to an app using Okta's api. Here's my request:

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

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

Why am I getting this error?

{
    "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": []
}
Alex Stybaev
  • 4,623
  • 3
  • 30
  • 44

2 Answers2

1

The request should be an HTTP PUT and have an empty JSON collection as the body.

Here is an example curl request

$ 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

Note that this example assumes the existence of two environment variables. If you want to run this curl command yourself, you must set those environment variables first. Here is an example of how to do that, make sure to replace the example values with the actual values for your Okta instance.

$ export OKTA_URL="https://example.okta.com"
$ export OKTA_APIKEY="01abCdefghIjkLMNOPqRsTUVW2xYZabcD3456efGhi"
Joël Franusic
  • 1,178
  • 8
  • 18
1

You may also do a POST to the /apps resource with the user context in the message body.

 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}}