This second post taking a look at the Document APIs explores the Agent Profile API; the component of the xAPI that allows you to store some additional data against a profile, such as whether that profile is part of a specific group that has access to additional settings or information.

In this post, we’ll look at how to use an API querying tool such as Postman to query the Agent Profile API using a practical example.

Querying the Agent Profile API

If you’ve not used Postman before, you may find it helpful to watch this video walkthrough as you work through the steps below:

 

Creating an Agent Profile

To create a agent profile, you can use a request similar to the one demonstrated below.

POST https://v2.learninglocker.net/v1/data/xAPI/agents/profile

URL Parameters

agent:{“objectType”: “Agent”, “name”: “John Smith”, “account”:{“name”: “123”, “homePage”: “http://www.example.com/users/”}}

profileId:http://www.example.com/profiles/1

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Content-Type:application/json

Body

{

   “favourite”: “It’s a Wonderful Life”,

   “cheesiest”: “Mars Attacks”

}

 

Retrieving an Agent Profile

To get a profile for an agent, you can use the Agent Profile API as demonstrated below.

GET https://v2.learninglocker.net/v1/data/xAPI/agents/profile

URL Parameters

agent:{“objectType”: “Agent”, “name”: “John Smith”, “account”:{“name”: “123”, “homePage”: “http://www.example.com/users/”}}

profileId:http://www.example.com/profiles/1

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Response

{

   “favourite”: “It’s a Wonderful Life”,

   “cheesiest”: “Mars Attacks”

}

 

Retrieving All Agent Profiles

You may want to retrieve all of the profiles associated with an agent. The request below demonstrates how that can be done via the Agent Profile API.

GET https://v2.learninglocker.net/v1/data/xAPI/agents/profile

URL Parameters

agent:{“objectType”: “Agent”, “name”: “John Smith”, “account”:{“name”: “123”, “homePage”: “http://www.example.com/users/”}}

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Response

[

   “http://www.example.com/profiles/1”

]

 

Deleting an Agent Profile

Finally, you may want to forget about the profile or remove an incorrect profile. This can be achieved with Agent Profile API as demonstrated in the request below.

DELETE https://v2.learninglocker.net/v1/data/xAPI/agents/profile

URL Parameters

agent:{“objectType”: “Agent”, “name”: “John Smith”, “account”:{“name”: “123”, “homePage”: “http://www.example.com/users/”}}

profileId:http://www.example.com/profiles/1

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

The final post in our Document API series looks at the Activity Profile API.

– – –

For more practical xAPI advice and support, download our free Technology Manager’s Guide to xAPI