SAP Knowledge Base Article - Public

2558226 - How to make/test the Learning API connection?

Symptom

How to make/test the Learning API connection?

Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.

Environment

SAP SuccessFactors Learning

Reproducing the Issue

The user gets a 403 error and does not get the bearer access token for the Learning API.

Cause

Often the Client Secret is not correct or has been incorrectly generated.

Resolution

Steps to confirm the Learning API is working as expected:

1. Get the Client Secret > This is generated in the Learning admin side > System Administration > Configuration > OAuth Token Server > Note: Generating a new Client Secret will invalidate all previously generated ones. Please ensure to note down the newly generated Client Secret. The system does not store the actual value but only the hashed one, so once you leave this page, it will not be possible to recover it >

1.jpg

2) Encode your Client Secret along with the Company ID (it is found in the Learning admin side > OAuth Token Server area) > Feel free to use any option to perform it, e.g.: https://www.base64encode.org > Put in the Company ID+:+the Newly Generated Client Secret (sample format: companyID:123abc456def) > Then, encode it and save the output > If you will use the "base64encode" site, when encoding, make sure no box is selected (boxes available above the "Encode" button) >

2.jpg

3) Go to your rest client (if you do not have one, it would be possible to go to the browser's store and install an add-on. In the example below, Firefox and RESTClient are being used) > Settings are as per the screenshot > Method - POST > URL - https://company.plateau.com/learning/oauth-api/rest/v1/token >

3.jpg

4) From the top of the screen, select "Headers" dropdown > Custom Headers > Name - Authorization > Value - Basic + the saved encode output (sample format: Basic 123abc456def > Click "Okay" >

4.jpg

5) Into the "Body" box, enter the following >

{

"grant_type":"client_credentials",

"scope":{

"userId":"userID",

"companyId":"Company ID",

"userType":"admin",

"resourceType":"learning_public_api"

}

}

Note: The "userType" value can be either "admin" or "user".

 5.jpg

6) Click "SEND" > See the response is 200 OK > At this point, it confirms the API is working and responding >

6.jpg

7) Take the value between the "" in the "Response Body (Raw)" tab >

7.jpg

8) Open a new rest client > Method - GET > URL - https://company.plateau.com > From the top of the screen, select "Headers" dropdown > Custom Headers > Name - Authorization > Value - Type the "Bearer" word > Put the value from the "Response Body (Raw)" tab that was generated in the previous step >

 8.jpg

9) You will need a second header > From the top of the screen, select "Headers" dropdown > Custom Headers > Name - Content-Type > Value - Application/json >

9.jpg

 

10) Place your code into the body > Below there is an example of a call to get the details on a student.

 {

  "recordLearningEvents": [

    {

      "studentID": "ID",

      "componentTypeID": "ID",

      "componentID": "ID",

      "revisionDate": 946684800000,

      "completionStatusID": "ID",

      "completionDate": 1508853045000,

      "completionTimeZoneID": "Europe/London",

      "revisionNumber": "1",

      "totalHours": 1,

      "instructorName": "instructor",

      "comments": "sample"

    }

  ]

}

10.jpg

See Also

Learning OData API Reference

Keywords

learning, api, client, secret, bearer, token, rest, generate, encode, oauth-api/rest/v1/token , KBA , LOD-SF-LMS-ODA , Web Services OData , LOD-SF-LMS , Learning Management System , LOD-SF-LMS-ADM , System Admin, Global Variables, References , How To

Product

SAP SuccessFactors Learning all versions