Making the course inactive in D2L using API - desire2learn

Is there a REST Api available for D2L which can be used to make a course inactive?

If it is an existing course, you can use the PUT method to Update a current course offering and set IsActive to false.
PUT /d2l/api/lp/(D2LVERSION: version)/courses/(D2LID: orgUnitId)
It expects the following JSON object:
{
"Name": "<string>",
"Code": "<string>",
"StartDate": "<string:UTCDateTime>|null",
"EndDate": "<string:UTCDateTime>|null",
"IsActive": "<boolean>"
}
You will likely want to retrieve the course offering information first, and then modify the IsActive flag and send back the full object data.
GET /d2l/api/lp/(D2LVERSION: version)/courses/(D2LID: orgUnitId)

Related

MS Team[BETA] API for Message object property type for reaction

I am trying to create the schema for Message API
As per the documentation, the sample response properties for reaction provided are below
Documentation sample response
"reactions": [
{
"reactionType": "like",
"createdDateTime": "2019-01-21T19:55:51.893Z",
"user": {
"application": null,
"device": null,
"conversation": null,
"user": {
"id": "e1ecb745-c10f-40af-a9d4-cab946c80ac7",
"displayName": null,
"userIdentityType": "aadUser"
}
}
}
]
From the documentation user is Identity type identity set
Identity is of type:
{
"displayName": "string",
"id": "string",
"tenantId": "string",
"thumbnails": { "#odata.type": "microsoft.graph.thumbnailSet" }
}
From the sample response as well as the response from endpoint, tenantId is not present.
There is a difference in sample response/actual endpoint response and documented properties:
The one with tenantId or one without tenantId.
The user is 1 level as per property documentation but as per actual response and sample response user property has user with in.
What is the correct schema of reaction property that we should consider, because we see variation in documentation vs actual response ?
ok, I think I understand - you're just asking what you should be coding for / expecting, when you query the api. It looks to me like the first link you've posted is the more correct, but you can verify this by using the Graph Explorer. This response does NOT bring back "tenantId", but you haven't explained if you -need- tenantId. If so, there are other ways to get it.
#KritikaVohra, Consider the response that you receive from the https://graph.microsoft.com/beta/teams/{id}/channels/{id}/messages. You don't need tenant id here. in case in conversation if you need it, you can use it from turnContext.

Eloqua's update event API endpoint overwrites instead of updating

I'm writing a script that will hit the Eloqua API to add a new sessions to an event as per the docs here. I'm using the endpoint /api/REST/2.0/assets/eventRegistration/{id} from the docs and doing a put request that looks like this:
{
"type": "EventRegistration",
"id": "131",
"sessions": [
{
"type": "EventSession",
"id": "46",
"name": "TEST+PUT+SESSION"
}
]
}
But that request overwrites the event and deletes any other sessions that already exist. Is there a way to tell the api to just add a new session and not overwrite or do I need to do a get request first and then a put?
All existing sessions are required when adding new sessions, so you will need to retrieve all sessions to include existing sessions in the PUT.

Look a message's text from events api response

I'm using slacks events API and have setup a subscription to the reactions_added event. Now when a reaction is added to a message, slack will send me a post body with all the details of the dispatched event as described here.
The problem I'm having is that I want to get the details, specifically the text of the message that my users have reacted to so I can parse/store etc that specific message. I assumed the message would return with some type of UUID that I could then respond to the callback and get the text, however I'm find it difficult to get the specific message.
The only endpoint I see available is the channels.history, which doesn't seem to give me the granularity I'm looking for.
So the tl;dr is: How do I look up a via slacks API, a messages text sent from the events API? Give the information I have the event_ts, channel and message ts I thought would be enough. I'm using the ruby slack-api gem FWIW.
You can indeed use the method channels.history (https://api.slack.com/methods/channels.history) to retrieve message from a public channel . The reaction_added dispatched event includes the channel ID and timestamp of the original message (in the item) and the combination of channelId + timestamp should be unique.
Be careful that you use the correct timestamp though. You need to use item.ts not event_ts
Full example dispatched event from the docs:
{
"token": "z26uFbvR1xHJEdHE1OQiO6t8",
"team_id": "T061EG9RZ",
"api_app_id": "A0FFV41KK",
"event": {
"type": "reaction_added",
"user": "U061F1EUR",
"item": {
"type": "message",
"channel": "C061EG9SL",
"ts": "1464196127.000002"
},
"reaction": "slightly_smiling_face"
},
"event_ts": "1465244570.336841",
"type": "event_callback",
"authed_users": [
"U061F7AUR"
]}
So calling channels.history with these values set should work:
latest = item.ts value
oldest = item.ts value
inclusive = 1
channel = item.channel value
If you want to get messages from a private channel you need to use groups.history.
https://api.slack.com/methods/channels.history

Restkit: How to get and map data from multiple source

I'm currently working on iOS Application with RestKit 0.20 to access data from Tastypie API.
And I am trying to get feeds data from URL like this
/api/v2/feed/?format=json
Then I will get array of feeds as below.
{
"meta": {
"limit": 20,
"next": null,
"offset": 0,
"previous": null,
"total_count": 2
},
"objects": [
{
"id": 1,
"info": "This is my first post",
"pub_date": "2013-02-03T15:59:33.311000",
"user": "/api/v2/user/1/",
"resource_uri": "/api/v2/feed/1/"
},
{
"id": 2,
"info": "second post, yeah",
"pub_date": "2013-02-03T16:00:09.350000",
"user": "/api/v2/user/1/",
"resource_uri": "/api/v2/feed/2/"
}
]
}
if I want to fetch more data about user which Tastypie send it as url like a foreign key "user": "/api/v2/user/1/", do I have to nested call objectRequestOperation.
I'm confusing because I'm using block to callback when data is successful loaded. So is there any better way than requesting user data again for each feed after requesting feed complete.
Thank you very much :)
You have to define in the Feed resource :
user = fields.ToOneField(UserResource, full=True)
More info in the tastypie doc http://django-tastypie.readthedocs.org/en/latest/resources.html
Why Resource URIs?
Resource URIs play a heavy role in how Tastypie delivers data. This can seem very different from other solutions which simply inline related data. Though Tastypie can inline data like that (using full=True on the field with the relation), the default is to provide URIs.
URIs are useful because it results in smaller payloads, letting you fetch only the data that is important to you. You can imagine an instance where an object has thousands of related items that you may not be interested in.
URIs are also very cache-able, because the data at each endpoint is less likely to frequently change.
And URIs encourage proper use of each endpoint to display the data that endpoint covers.
Ideology aside, you should use whatever suits you. If you prefer fewer requests & fewer endpoints, use of full=True is available, but be aware of the consequences of each approach.

Desire2Learn Valence API user ID

What is the preferred method for obtaining the user ID used in the following Valence Grades API?
PUT /d2l/api/le/(D2LVERSION: version)/(D2LID: orgUnitId)/grades/(D2LID: gradeObjectId)/values/(D2LID: userId)
Is the user id here the same as the token ID received during authentication, or do you call the "whoami" API, or is it something else?
The "whoami" call provides data on the current UserContext you are working in (the token value you get back during the auth step). For example, if you are logged in as an Administrator, that would provide back the Administrator's userId.
WhoAmI API Call
GET /d2l/api/lp/(D2LVERSION: version)/users/whoami
This will give you the information on the current UserContext
{
"Identifier": "<string:D2LID>",
"FirstName": "<string>",
"LastName": "<string>",
"UniqueName": "<string>",
"ProfileIdentifier": "<string:D2LID>"
}
If you are looking for the UserIds for the users in a particular orgUnit, I would make the following call:
Classlist API Call
GET /d2l/api/le/(D2LVERSION: version)/(D2LID: orgUnitId)/classlist/
This will give you an array of ClasslistUsers
{
"Identifier": "<string:D2LID>",
"ProfileIdentifier": "<string:D2LID>",
"DisplayName": "<string>",
"UserName": "<string>|null",
"OrgDefinedId": "<string>|null",
"Email": "<string>|null"
}
The "Identifier" value in either case is the one you will want to use for (D2LID:UserId)

Resources