Eloqua's update event API endpoint overwrites instead of updating - eloqua

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.

Related

Is it possible to pass AWS EventBridge rule event variables to the target Invocation HTTP Parameters?

I am pretty sure I miss something simple but I don't seem to fins any resource on my issue and I am a novice on AWS.
The problem is as follows: I have a scenario where I would like to trigger a REST POST API when files are uploaded to an S3 bucket. This POST API uses OAuth 2.0 and requires the file name in the body.
I created a rule that successfully triggers on upload and the API works well if I put a static filename as Invocation Http Parameter. But I would like this value to be dynamic, based on the file that triggers the event.
I have tried using the jQuery snippet $.detail.object.key but, as much as it works for adding a Query Parameter from the rule, it doesn't seem to work if used in the Invocation Http Parameters settings in the API connection.
The event pattern is as follows:
{
"source": ["aws.s3"],
"detail-type": ["Object Created"],
"detail": {
"bucket": {
"name": ["jna-test-bucket"]
},
"object": {
"key": [{
"prefix": "testFileForAPI"
}]
}
}
}

Using createLink to share with specific users

I am trying to create a link to share a document with createLink from Microsoft Graph for specific users without using an invite but it is creating a link with Anyone with the link can edit this document permission.
I'm calling this endpoint:
POST /me/drive/items/{itemId}/createLink
With this request body:
{
"type": "edit",
"scope": "anonymous"
}
Am I missing something?
You can't use createLink for sharing with a specific person, you need to use the invite endpoint for that.
The call you're making is responding exactly how you've asked it to and generating a link (createLink) that anyone (anonymous) can access.
If you don't want to send a physical invitation, you can tell OneDrive this by setting the sendInvitation property to false:
POST /me/drive/items/{item-id}/invite
Content-type: application/json
{
"requireSignIn": true,
"sendInvitation": false,
"roles": [ "write", "read"],
"recipients": [
{
"email": "someone#contoso.org"
}
]
}
Please refer this link https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_invite
You can share the file with specific user by adding user's in
"recipients":[{"#odata.type":"microsoft.graph.driveRecipient"}]
parameter. You can set sendInvitation parameter like "sendInvitation":false to avoid sending the invitation mail.

With Rails 4 and structured logging, how can I add the request id field to logs?

I am adding structured logging to a Rails 4 app. Using lograge and logstash-logger as describe in this article, I've got things mostly working.
I'm having trouble adding request id to the logs. The closest I've found is to add this to config/${ENV}.rb:
config.log_tags = [:uuid]
But this adds the request id to the tags list, instead of adding it as a named field.
{
"tags": [
"da76b4be-01ae-4cc4-8d3c-87062ea02cfe"
],
"host": "services",
"severity": "DEBUG",
"#version": "1",
"#timestamp": "2016-09-13T17:24:34.883+00:00",
"message": "..."
}
This is problematic. It makes it more awkward and less obvious on how to search for a particular request id. Plus, parsing the message in logstash it overwrites any other tags that are already associated with the log message.
Is there any way that I can add the request id to the log as a named field?
{
"request_id", "da76b4be-01ae-4cc4-8d3c-87062ea02cfe",
"host": "services",
"severity": "DEBUG",
"#version": "1",
"#timestamp": "2016-09-13T17:24:34.883+00:00",
"message": "..."
}
Old question but maybe it will help someone like me who struggled to find a simple way to do this.
Using the custom_payload (instead of custom_options), you can directly access the request received by the controller and get its id to add it to the logs:
config.lograge.custom_payload do |controller|
{
request_id: controller.request.request_id
}
end
No need to configure the log_tags for this to work.
There are several ways to do this. From Lograge, you can use the custom_options:
# all your lograge stuff...
config.lograge.enabled = true
config.lograge.custom_options = lambda do |event|
# use the `event.payload`
{uuid: event.payload[:uuid]}
end
You can overload any option in here - they'll take over the lib's ones.
The code responsible for this is here. The test that shows it work is here.

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.

Making the course inactive in D2L using API

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)

Resources