How to extract all task ID's for a specific user IBM BPM - business-process-management

I am trying to extract the task ID's for a specific user ( using username) in the IBM BPM REST API tester.
I have tried using the following command but it does not return the task ID
rest/bpm/wle/v1/search/query?columns=taskId%2C&condition=userName%7COSHVWYK&organization=byInstance&run=true&shared=false&filterByCurrentUser=false

Your condition is misformatted. On IBM BPM 8.6 go to REST API Tester / Business Process Manager REST APIs / Search API / Run Query [deprecated] and specify Condition as assignedToUser|Equals|user123 (replacing user123 with real user name);
note that list of columns allowed in Condition is available under /rest/bpm/wle/v1/search/meta/constraintColumn. Adding to Columns value of taskId will narrow returned data set, so this is optional.
Result URL looks then this way:
rest/bpm/wle/v1/search/query?condition=assignedToUser%7CEquals%7Cuser123&organization=byInstance&run=true&shared=false&filterByCurrentUser=false
And result set will have structure like following:
{
"status": "200",
"data": {
"data": [{
"assignedToRole": null,
"taskAssignedTo": {
"type": "User",
"who": "user123"
},
"instanceId": 308611,
"instanceStatus": "Terminated",
"taskAttachedExtActivityRef": null,
"taskAttachedInfoPathFormRef": null,
"taskId": 613750,
"taskStatus": "Closed"
}, {
"assignedToRole": null,
"taskAssignedTo": {
"type": "User",
"who": "user123"
},
"instanceId": 308622,
"instanceStatus": "Terminated",
"taskAttachedExtActivityRef": null,
"taskAttachedInfoPathFormRef": null,
"taskId": 613763,
"taskStatus": "Closed"
}, ... ]
}
}

Related

Access Nested Netsuite Ruby Hash

I am trying to access a Netsuite Ruby Hash (Netsuite gem) and return orders which need updating from the db, the process uses two service objects, one to get the orders from db, (ListOrdersService), and the this file to compare those against modified ones in Netsuite. Is all working except I am having problems getting some of the nested values in Netsuite in to the output. Code is below with a troublesome item commented out. Its just an each method which compares dates then puts the needed orders in returned value.
def process_order_updates
get_order_updates = []
# Get all our open orders from DB
bj_open_orders = ListOrdersService.new.call
# Get all identical open orders from Netsuite
bj_open_orders.each do |item|
netsuite_sales_orders = NetSuite::Records::SalesOrder.get(item['sales_order_internal_id'])
# Compare the last modified date from Netsuite to the last checked date from app DB
if netsuite_sales_orders.present? && netsuite_sales_orders.last_modified_date > item['last_checked_date']
# If the last modified date is newer, then we create a new hash with the updated order info
get_order_updates << {
sales_order_internal_id: item['sales_order_internal_id'],
order_status: item['order_status']
# quantity_fulfilled: item['items_list']['item']['quantity_fulfilled']
}
puts "still open order #{item['sales_order_internal_id']} needs to be updated, it was last checked by at #{item['last_checked_date']} but it was just modified, on #{netsuite_sales_orders.last_modified_date}"
end
end
puts "Here are the orders that need to be updated: #{get_order_updates}"
end
The Netsuite file code I am referencing is below, and trying to get quantity_fulfilled, quantity_billed, and some others in the file. items_list is a top level item
"item_list": {
"list": [
{
"attributes": {
"item": {
"internal_id": "110",
"external_id": null,
"type": null,
"attributes": {
"name": "000002 Kerosene (UN1223) 3.PGIII (D/E)"
}
},
"expand_item_group": false,
"quantity": "1000.0",
"units": {
"internal_id": "1",
"external_id": null,
"type": null,
"attributes": {
"name": "ltr"
}
},
"description": "Kerosene (UN1223) 3.PGIII (D/E)",
"price": {
"internal_id": "-1",
"external_id": null,
"type": null,
"attributes": {}
},
"rate": "0.81",
"amount": "810.0",
"is_closed": false,
"gross_amt": "850.5",
"line": "1",
"cost_estimate_type": "_averageCost",
"cost_estimate": "900.79",
"quantity_back_ordered": "0.0",
"quantity_billed": "0.0",
"quantity_committed": "1000.0",
"quantity_fulfilled": "0.0",
"tax1_amt": "40.5",
"tax_code": {
"internal_id": "2214",
"external_id": null,
"type": null,
"attributes": {
"name": "VAT:RDR-5%"
}
},
Any tips on how to get those items, directly or with a hashmap welcome Thanks

How to get activities on specific Item in OneDrive for business API

I'm trying to get DriveItem activities on OneDrive for business using this Graph API https://learn.microsoft.com/en-us/graph/api/itemactivitystat-getactivitybyinterval?view=graph-rest-1.0&tabs=csharp
But the Activity property of the returned response is always null and I can not get what I need (activities on the specific DriveItem, like edits, comments etc.)
Definitely there are some activities for that driveItem, webhook is triggered on item change and I'm able to track changes using delta API: https://learn.microsoft.com/en-us/graph/delta-query-overview.
The code I'm using is like this:
var request = new GraphServiceClient(new DelegateAuthenticationProvider(msg =>
{
msg.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
return Task.CompletedTask;
}))
.Drives[driveId].Items[driveItemId]
.GetActivitiesByInterval(start, end, "day")
.Request();
var resultPage = await request.GetAsync();
The full response with Activities == null is below:
{
"Access": {
"ActionCount": 3,
"ActorCount": 1,
"AdditionalData": {
"timeSpentInSeconds": {
"ValueKind": 4
}
},
"ODataType": null
},
"Create": null,
"Delete": null,
"Edit": null,
"EndDateTime": "2022-02-12T23:59:59+00:00",
"IncompleteData": {
"MissingDataBeforeDateTime": null,
"WasThrottled": false,
"AdditionalData": {
"resultsPending": {
"ValueKind": 6
},
"notSupported": {
"ValueKind": 6
}
},
"ODataType": null
},
"IsTrending": null,
"Move": null,
"StartDateTime": "2022-02-12T00:00:00+00:00",
"Activities": null,
"ActivitiesNextLink": null,
"Id": null,
"ODataType": "#microsoft.graph.itemActivityStat",
"AdditionalData": {
"aggregationInterval": {
"ValueKind": 3
}
}
}
Is there a way to get a list of activities for the specific OneDrive item through API (comments, edits, etc.)?
The only way of getting user activities I've found so far is to use this SharePoint site list API instead of OneDrive API directly: https://learn.microsoft.com/en-us/graph/api/list-get?view=graph-rest-1.0&tabs=csharp
,where {list-id} is user's SharePoint site list named userActivityFeedHiddenList.
The API response is a bit cryptic, but it's possible to see who commented what on a document and when.
Response examples can be found here https://charleslakes.com/2020/09/28/onedrive-hidden-list-user-activity/

Microsoft Teams cloud calling/graph-is there a way to have a bot add a PSTN participant to a meeting?

Using the C# calling SDK for Graph, I can join a bot to a meeting, and add participants by GUID from the same tenant. Where this falls apart though is adding a participant from PSTN/direct routing. If I have a regular user add a participant, I see this update:
"#odata.type": "#microsoft.graph.participant",
"info": {
"#odata.type": "#microsoft.graph.participantInfo",
"identity": {
"#odata.type": "#microsoft.graph.identitySet",
"phone": {
"#odata.type": "#microsoft.graph.identity",
"id": "+19054181287",
"identityProvider": "None"
}
},
"endpointType": "default"
},
Seems reasonable enough, so I tried adding a participant like this:
InvitationParticipantInfo target = new InvitationParticipantInfo { Identity = new IdentitySet(), };
target.Identity.SetInAdditionalData("phone", new Identity() { Id = targetID });
target.Identity.AdditionalData["phone"].SetInAdditionalData("tenantId", m_tenantID);
target.Identity.AdditionalData["phone"].SetInAdditionalData("identityProvider", "None");
target.EndpointType = EndpointType.Default;
await call1.Participants.InviteAsync(new List<InvitationParticipantInfo>() { target });
Which generates a request that looks like this (interesting that the identityProvider changed):
"participants": [
{
"#odata.type": "#microsoft.graph.invitationParticipantInfo",
"identity": {
"#odata.type": "#microsoft.graph.identitySet",
"phone": {
"#odata.type": "#microsoft.graph.identity",
"id": "+19054181287",
"tenantId": "8c6ae172-a3ea-4f50-994d-a0256822697f",
"identityProvider": "(Generic: l3QstqQ1)"
}
},
"endpointType": "default"
}
And that comes back with this:
Action failed: 81bd4426-7200-4c50-acba-f17b7a987322
exception: Code: 7505
Message: Request authorization tenant mismatch.
Scenario Id: 46ffbff3-bf9f-4b6d-a639-974c07b959dc
Inner error:
AdditionalData:
date: 2020-10-13T18:45:30
request-id: 5d152942-dc10-4baa-bb28-48bf991f944b
client-request-id: 83f84370-3708-4e3c-a34d-2f69bd8eb8a7
Given that the meeting organizer has permissions for PSTN dialout, as do invitees, is there a reason that a bot shouldn't be able to add a participant like this? What's interesting is that something very similar does work for redirecting/transferring incoming PSTN calls. The "Request authorization tenant mismatch" seems like a red herring (since it's all the same tenant)-is this just a case of "not supported right now"? I know PSTN calls from bots are (still) not officially supported, but I was curious whether anyone had a way to make this work?

Create OnlineMeeting in MS Graph with Call-in Info

I am building some utilities to automate aspects of Microsoft Teams at my company. One thing we are trying is automating scheduling/creation of Online Meetings under various circumstances. Overall this is working fine, but I can't figure out how to get / attach telephone call-in information for the calls we're creating.
Here's an example POST /app/onlineMeetings:
{
"meetingType": "meetNow",
"participants": {
"organizer": {
"identity": {
"user": {
"id": "<user-id>"
}
}
}
},
"subject": "Personal Room"
}
And here's what a typical response looks like:
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#app/onlineMeetings/$entity",
"joinUrl": "<join-url>",
"subject": "Personal Room",
"isCancelled": false,
"meetingType": "MeetNow",
"accessLevel": "SameEnterprise",
"id": "<meeting-id>",
"audioConferencing": null,
"meetingInfo": null,
"participants": {
"organizer": {
"upn": "<user-name>",
"sipProxyAddress": "<user-name>",
"identity": {
}
},
"attendees": []
},
"chatInfo": {}
}
As you can see, the audioConferencing key is null. If a user accesses the joinUrl, they can join the call and audio conferencing information is displayed at that time -- but I can't figure out how to get it out in advance (e.g. to send in an email).
Also note that since this is not a VTC-enabled meeting, the id can't be used to issue a new GET request for additional information, as discussed here

How to retrieve contents of an itemAttachment via the Microsoft Graph API

I'm currently developing a solution which is retrieving e-mails via the Microsoft Graph API. In november 2015 Microsoft stated it is ready for production and I've read in another forum post that if you start now on developing using a Microsoft API, you should use the Graph API, since it is the future.
Everything is going well except for one thing and that is the following.
I must retrieve e-mails. Inside these e-mails there are of course attachments. These attachments come in some variaties. fileAttachment (images, documents etc.), referenceAttachments and itemAttachments (outlook-item). The issue here is with the itemAttachments. An itemAttachment can be anything from an appointment to another message. The problem here is that I'm not able to get and retrieve the contentBytes in some way which is working for fileAttachments. A related object to itemAttachment is outlookItem. There is also a page with a description made for this outlookItem, but the examples and the details are missing.
The user rights are set to Mail.Read and Mail.ReadWrite.
Links:
General overview: http://graph.microsoft.io/docs/overview/overview
Get outlookItem (empty?):
Example call and response I get. Please note the types of the attachments.
https://graph.microsoft.com/v1.0 /users/ /messages/ /attachments
{
"#odata.context": "link",
"value": [
{
"#odata.type": "#microsoft.graph.fileAttachment",
"id": "AAMkAGU2NmIwMTcxLTljYzUtNGRiMi1hZjczLTllNzhiZDRiNWZlZABGAAAAPAD_Lx_gimDGRqSr98J_O_e6BwDcWyYHlO7rS5_XpLHCx6NSAAIMC0V-AADcWyYHlO7rS5_XpLHCx6NSAAIMC6RgAAABEgAQAGhN_vm1RlBPt7V4N9a89UY=",
"lastModifiedDateTime": "2016-01-13T14:25:33Z",
"name": "image001.png",
"contentType": "image/png",
"size": 5077,
"isInline": true,
"contentId": "image001.png#01D14E16.A3A32480",
"contentLocation": null,
"contentBytes": "iVBORw0KGgoAAAANSUhEUgAAAKAAAACCCAIAAABOyVRHAAAAAXNSR0IArs4c6QAAEndJREFUeF7tXQ1QFFe2bkbU... (truncated)"
},
{
"#odata.type": "#microsoft.graph.fileAttachment",
"id": "AAMkAGU2NmIwMTcxLTljYzUtNGRiMi1hZjczLTllNzhiZDRiNWZlZABGAAAAPAD_Lx_gimDGRqSr98J_O_e6BwDcWyYHlO7rS5_XpLHCx6NSAAIMC0V-AADcWyYHlO7rS5_XpLHCx6NSAAIMC6RgAAABEgAQAFnSLgIC5wZOosmLtBWK8gE=",
"lastModifiedDateTime": "2016-01-13T14:25:34Z",
"name": "image002.png",
"contentType": "image/png",
"size": 3722,
"isInline": true,
"contentId": "image002.png#01D14E16.A3A32480",
"contentLocation": null,
"contentBytes": "iVBORw0KGgoAAAANSUhEUgAAAPoAAABSCAYAAAB9o8m+AAAAGXRFWHRTb... (truncated)"
},
{
"#odata.type": "#microsoft.graph.fileAttachment",
"id": "AAMkAGU2NmIwMTcxLTljYzUtNGRiMi1hZjczLTllNzhiZDRiNWZlZABGAAAAPAD_Lx_gimDGRqSr98J_O_e6BwDcWyYHlO7rS5_XpLHCx6NSAAIMC0V-AADcWyYHlO7rS5_XpLHCx6NSAAIMC6RgAAABEgAQANOuw7m8sW1Ot3MivYQ5OYU=",
"lastModifiedDateTime": "2016-01-13T14:25:24Z",
"name": "Knipsel.PNG",
"contentType": null,
"size": 7641,
"isInline": false,
"contentId": null,
"contentLocation": null,
"contentBytes": "iVBORw0KGgoAAAANSUhEUgAAAKAAAACCCAYAAADBq8MQAAA... (truncated)"
},
{
"#odata.type": "#microsoft.graph.itemAttachment",
"id": "AAMkAGU2NmIwMTcxLTljYzUtNGRiMi1hZjczLTllNzhiZDRiNWZlZABGAAAAPAD_Lx_gimDGRqSr98J_O_e6BwDcWyYHlO7rS5_XpLHCx6NSAAIMC0V-AADcWyYHlO7rS5_XpLHCx6NSAAIMC6RgAAABEgAQAPEUC740tjtAlNTe8NpopUI=",
"lastModifiedDateTime": "2016-01-14T15:55:07Z",
"name": "RE: Test met plaatje",
"contentType": null,
"size": 36972,
"isInline": false
}
]
}
I've tried to change the GET-statement by pasting the attachment id with or without the messages path and the expand feature (which is only supported one level deep), but I can't seem te find the solution.
Something I've found is this question, which is kind of the same, however it is for the office365 unified API. How to retrieve ItemAttachment contents from Office 365 REST API?.
So, the question: How can I retrieve the contents of an outlookItem via the Microsoft Graph API? And how do I know what to expect? Can anybody help me getting past this obstacle.
Use $expand option:
GET https://graph.microsoft.com/v1.0/me/messages('AAMkADA1M-zAAA=')/attachments('AAMkADA1M-CJKtzmnlcqVgqI=')/?$expand=microsoft.graph.itemattachment/item
Response:
HTTP/1.1 200 OK
Content-type: application/json
{
"#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('d1a2fae9-db66-4cc9-8133-2184c77af1b8')/messages('AAMkADA1M-zAAA%3D')/attachments/$entity",
"#odata.type":"#microsoft.graph.itemAttachment",
"id":"AAMkADA1MCJKtzmnlcqVgqI=",
"lastModifiedDateTime":"2017-07-21T00:20:34Z",
"name":"Reminder - please bring laptop",
"contentType":null,
"size":32005,
"isInline":false,
"item#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('d1a2fae9-db66-4cc9-8133-2184c77af1b8')/messages('AAMkADA1M-zAAA%3D')/attachments('AAMkADA1M-CJKtzmnlcqVgqI%3D')/microsoft.graph.itemAttachment/item/$entity",
"item":{
"#odata.type":"#microsoft.graph.message",
"id":"",
"createdDateTime":"2017-07-21T00:20:41Z",
"lastModifiedDateTime":"2017-07-21T00:20:34Z",
"receivedDateTime":"2017-07-21T00:19:55Z",
"sentDateTime":"2017-07-21T00:19:52Z",
"hasAttachments":false,
"internetMessageId":"<BY2PR15MB05189A084C01F466709E414F9CA40#BY2PR15MB0518.namprd15.prod.outlook.com>",
"subject":"Reminder - please bring laptop",
"importance":"normal",
"conversationId":"AAQkADA1MzMyOGI4LTlkZDctNDkzYy05M2RiLTdiN2E1NDE3MTRkOQAQAMG_NSCMBqdKrLa2EmR-lO0=",
"isDeliveryReceiptRequested":false,
"isReadReceiptRequested":false,
"isRead":false,
"isDraft":false,
"webLink":"https://outlook.office365.com/owa/?ItemID=AAMkADA1M3MTRkOQAAAA%3D%3D&exvsurl=1&viewmodel=ReadMessageItem",
"body":{
"contentType":"html",
"content":"<html><head>\r\n</head>\r\n<body>\r\n</body>\r\n</html>"
},
"sender":{
"emailAddress":{
"name":"Adele Vance",
"address":"AdeleV#contoso.onmicrosoft.com"
}
},
"from":{
"emailAddress":{
"name":"Adele Vance",
"address":"AdeleV#contoso.onmicrosoft.com"
}
},
"toRecipients":[
{
"emailAddress":{
"name":"Alex Wilbur",
"address":"AlexW#contoso.onmicrosoft.com"
}
}
],
"ccRecipients":[
{
"emailAddress":{
"name":"Adele Vance",
"address":"AdeleV#contoso.onmicrosoft.com"
}
}
]
}
}
Source: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/attachment_get#request-2
The official documentation: https://graph.microsoft.io/en-us/docs/api-reference/beta/api/attachment_get.htm . Use valid Bearer authentication access code, and check for appropriate Graph API permissions on the Azure management portal. Attachment is based64 encoded string, coming in the contentBytes field. Correct Uri for loading list of a message attachments is: https://graph.microsoft.com/beta/me/messages/[ message Id ]/attachments. Sample code to call attachments endpoint is below:
using (var client = new HttpClient())
{
using (var request = new HttpRequestMessage(HttpMethod.Get,
"https://graph.microsoft.com/beta/me/messages/..id../attachments"))
{
request.Headers.Authorization =
new AuthenticationHeaderValue("Bearer", "...valid access token...");
using (HttpResponseMessage response = await client.SendAsync(request))
{
if (response.StatusCode == HttpStatusCode.OK)
{
result = await response.Content.ReadAsStringAsync();
var json = JObject.Parse(result);
}
}
}
}
Get attachment using MS Graph API for Java:
First build the graph client. Sample code
ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId(yourClientId).clientSecret(yourClientSecret)
.tenantId(yourTenantId).build();
TokenCredentialAuthProvider tokenCredAuthProvider = new TokenCredentialAuthProvider(clientSecretCredential);
GraphServiceClient<Request> gClient = GraphServiceClient.builder().authenticationProvider(tokenCredAuthProvider)
.buildClient();
Either get all the attachments for a message-
FileAttachment fa = (FileAttachment) graphClient.users(id).messages(messageId).attachments().buildRequest().get();
Or get a particular attachment by passing the attachment id:
FileAttachment fa = (FileAttachment) graphClient.users(id).messages(messageId).attachments(attachmentId).buildRequest().get();
//Copy file attachment into a File from byte stream using FileUtils.
FileUtils.writeByteArrayToFile(new File(yourFileLocation), fa.contentBytes);
You can also similarly either get all users, messages or attachments or pass particular id to get a unique result for these entities.

Resources