I am using ASP.Net Core 3.1 and Microsoft Graph Beta 0.15. How can i delete the recurrence settings of an event.
I tried by setting the Recurrence property to null but it has no effect.
Event graph = new Event();
...
event.Recurrence = null;
await graphServiceClient.Me.Events[id].Request().UpdateAsync(event);
This is possible by executing a PATCH request through the Microsoft Graph Explorer as mentioned in
this post
PATCH https://graph.microsoft.com/beta/users/me/events/{id}
Content-type: application/json
{
"recurrence": null,
}
Any help will be appreciated, Thanks
Try using AdditionalData property
var additionalData = new Dictionary<string, object>();
additionalData.Add("recurrence", null);
event.AdditionalData = additionalData;
This is a limitation of the SDK today as documented here. The workaround is to build the request and execute it yourself.
Related
We are using SAP SDK 3.25.0 and calling a batch request Read query passing some filters. I am getting the response of all the records and it can be seen that the filter is not working properly.
I have referred this blog here but I am getting the same issue of decode URL issue YY1_QuantityContractTracki?$filter=((CustomerName eq %27Ford%27) and (SalesSchedulingAgreement eq %270030000141%27)) and (PurchaseOrderByCustomer eq %27TEST%27)&$select=SalesSchedulingAgreement,PurchaseOrderByCustomer,Customer,CustomerName,SalesSchedulingAgreementItem,Material,MaterialByCustomer&$format=json
Below is the query program which I am using.
Am I missing something here. Please let us know
Thanks,
Arun Pai
final BatchRequestBuilder builder = BatchRequestBuilder.withService("/sap/opu/odata/sap/YY1_QUANTITYCONTRACTTRACKI_CDS");
for (Contract contract : contracts) {
FilterExpression mainFilter = new FilterExpression("CustomerName", "eq", ODataType.of(contract.getCustomerName()))
.and(new FilterExpression("SalesSchedulingAgreement", "eq", ODataType.of(contract.getSchAgrmntNo())))
.and(new FilterExpression("PurchaseOrderByCustomer", "eq", ODataType.of(contract.getCustRefNo())));
final ODataQuery oDataQuery = ODataQueryBuilder
.withEntity(sapConfig.getEssentialsContractServiceUrl(),
sapConfig.getEssentialsContractListEntity())
.select("SalesSchedulingAgreement", "PurchaseOrderByCustomer", "Customer", "CustomerName",
"SalesSchedulingAgreementItem", "Material", "MaterialByCustomer")
.filter(mainFilter)
.build();
builder.addQueryRequest(oDataQuery);
}
final BatchRequest batchRequest = builder.build();
final BatchResult batchResult = batchRequest.execute(httpClient);
Update
I have changed the version to 3.35.0 today with connectivity version 1.40.11 but it did'nt work either.
Below is the log request which gets printed in the console
2021-01-15 19:15:03.831 INFO 42640 --- [io-8084-exec-10] c.s.c.s.o.c.impl.BatchRequestImpl : --batch_123
Content-Type: application/http
Content-Transfer-Encoding: binary
GET YY1_QuantityContractTracki?%24filter%3D%28%28CustomerName+eq+%2527Ford27%29+and+%28SalesSchedulingAgreement+eq+%25270030000141%2527%29%29+and+%28PurchaseOrderByCustomer+eq+%2527TEST%2527%29%26%24select%3DSalesSchedulingAgreement%2CPurchaseOrderByCustomer%2CCustomer%2CCustomerName%2CSalesSchedulingAgreementItem%2CMaterial%2CMaterialByCustomer%26%24format%3Djson HTTP/1.1
Accept: application/json;odata=verbose
--batch_123--
For your information: with the release of SAP Cloud SDK 3.41.0 we enabled support for read operations in OData batch requests on the type-safe API. Please find the chapter in the respective documentation. You would no longer need to use the Generic OData Client of SAP Cloud SDK as suggested in the other response. Example:
BusinessPartnerService service;
BusinessPartnerAddress addressToCreate1;
BusinessPartnerAddress addressToCreate2;
BusinessPartnerFluentHelper requestTenEntities = service.getAllBusinessPartner().top(10);
BusinessPartnerByKeyFluentHelper requestSingleEntity = service.getBusinessPartnerByKey("bupa9000");
BatchResponse result =
service
.batch()
.addReadOperations(requestTenEntities)
.addReadOperations(requestSingleEntity)
.executeRequest(destination);
List<BusinessPartner> entities = result.getReadResult(requestTenEntities);
BusinessPartner entity = result.getReadResult(requestSingleEntity);
Update (22.03.2021)
With the release of SAP Cloud SDK 3.41.0 this week we'll enable support for read operations in OData batch requests on the type-safe API. Please find the chapter in the respective documentation.
Example:
BusinessPartnerService service;
BusinessPartnerAddress addressToCreate1;
BusinessPartnerAddress addressToCreate2;
BusinessPartnerFluentHelper requestTenEntities = service.getAllBusinessPartner().top(10);
BusinessPartnerByKeyFluentHelper requestSingleEntity = service.getBusinessPartnerByKey("bupa9000");
BatchResponse result =
service
.batch()
.addReadOperations(requestTenEntities)
.addReadOperations(requestSingleEntity)
.executeRequest(destination);
List<BusinessPartner> entities = result.getReadResult(requestTenEntities);
BusinessPartner entity = result.getReadResult(requestSingleEntity);
Original response:
I'm from the SAP Cloud SDK team. Generally we recommend our users to generate classes for their OData service interactions. This way you can easily make sure that requests are according to specification, while type safety is taken care of.
Unfortunately I cannot help you with the API of BatchRequestBuilder, BatchRequest or BatchResult because they are not directly a part of SAP Cloud SDK and not maintained by us. Instead we suggest our own request builders.
If the generation of classes, as linked above, is not an option for you, then I would suggest to try our expert API featuring the Generic OData Client of SAP Cloud SDK. This is the code that we would also use internally for our generated request builders:
String servicePath = "/sap/opu/odata/sap/YY1_QUANTITYCONTRACTTRACKI_CDS";
ODataRequestBatch requestBatch = new ODataRequestBatch(servicePath, ODataProtocol.V2);
Map<Contract, ODataRequestRead> batchedRequests = new HashMap<>();
// iterate over contracts, construct OData query objects and add them to the OData batch request builder
for (Contract contract : contracts) {
String entityName = sapConfig.getEssentialsContractListEntity();
String serviceUrl = sapConfig.getEssentialsContractServiceUrl();
StructuredQuery structuredQuery = StructuredQuery.onEntity(entityName, ODataProtocol.V2);
structuredQuery.select("SalesSchedulingAgreement", "PurchaseOrderByCustomer", "Customer", "CustomerName", "SalesSchedulingAgreementItem", "Material", "MaterialByCustomer");
structuredQuery.filter(FieldReference.of("SalesSchedulingAgreement").equalTo(contract.getSchAgrmntNo()));
structuredQuery.filter(FieldReference.of("PurchaseOrderByCustomer").equalTo(contract.getCustRefNo()));
String encodedQuery = structuredQuery.getEncodedQueryString();
ODataRequestRead requestRead = new ODataRequestRead(serviceUrl, entityName, encodedQuery, ODataProtocol.V2);
batchedRequests.put(contract, requestRead);
requestBatch.addRead(requestRead);
}
// execute the OData batch request
ODataRequestResultMultipartGeneric batchResult = requestBatch.execute(httpClient);
// extract information from batch response, by referring to the individual OData request references
for( Map.Entry<Contract, ODataRequestRead> requestMapping : batchedRequests.entrySet() ) {
ODataRequestResultGeneric queryResult = batchResult.getResult(requestMapping.getValue());
List<Map<String, Object>> itemsForQuery = queryResult.asListOfMaps();
}
Kind regards
Alexander
I created teams in Microsoft Teams (from groups as documented here) via the C# graph-api sdk without any problems - everything was working just fine.
But suddenly this is not working anymore. I will always get the following exception at the line return await graphServiceClient.Teams.Request().AddAsync(team);:
Message: Failed to execute Templates backend request
CreateTeamFromGroupWithTemplateRequest. Request Url:
https://teams.microsoft.com/fabric/emea/templates/api/groups/theGroupId/team,
Request Method: PUT,
And further:
Team Visibility can not be specified as it is inherited from the
group.
I know that the visibility property must not be set if creating the team from a group as it states in the Microsoft documentation:
The team that's created will always inherit from the group's display name, visibility, specialization, and members. Therefore, when making this call with the group#odata.bind property, the inclusion of team displayName, visibility, specialization, or members#odata.bind properties will return an error.
But the currently used code below shows that I am not setting any forbidden properties - and this code worked for the last few days, too:
private async Task<Team> CreateTeamFromGroup(string groupId)
{
var graphServiceClient = [...]
var groupResourceLink = $"https://graph.microsoft.com/v1.0/groups('{groupId}')";
var team = new Team
{
AdditionalData = new Dictionary<string, object>()
{
{ "template#odata.bind", "https://graph.microsoft.com/beta/teamsTemplates('standard')" },
{ "group#odata.bind", groupResourceLink }
},
Channels = new TeamChannelsCollectionPage
{
new Channel
{
DisplayName = "WhatEver"
}
}
};
return await graphServiceClient.Teams.Request().AddAsync(team);
}
Is anyone else experiencing this problem? Was there an API change? Was the teams backend changed? Anyone any ideas?
P.S.: I am using the latest NuGet-Package for Microsoft Graph - downgrading didn't help.
Update (with a not very satisfying work-around)
The error can be reproduced via the graph api explorer, too.
The POST command above issues a PUT command, that is described here. With this request, the team can be created.
The documentation and the graph api snippet for C# is out-dated, though. You have to add odatatype = null to the properties when using the sdk
Unfortunately it is not possible to add channels in the same step. If you specify the property 'channels' it will just be ignored.
Update (Detailed error message)
System.AggregateException: 'One or more errors occurred. (Code:
BadRequest Message: Failed to execute Templates backend request
CreateTeamFromGroupWithTemplateRequest. Request Url:
https://teams.microsoft.com/fabric/emea/templates/api/groups/theGroupId/team,
Request Method: PUT, Response Status Code: BadRequest,
ErrorMessage : {"errors":[{"message":"Team Visibility can not be
specified as it is inherited from the
group."}],"operationId":"639448e414ece64caee8f52839585bf7"} Inner
error: AdditionalData: date: 2020-11-24T10:21:22 request-id:
37a28cac-3ac5-4bd2-a061-daf44c442fac client-request-id:
37a28cac-3ac5-4bd2-a061-daf44c442fac ClientRequestId:
37a28cac-3ac5-4bd2-a061-daf44c442fac )'
Just tested this morning and I can say, that the "old way" by using the beta API to create a team with a template works again. Don't know, how many other ways exist to do these things, but here is our current request, that works now (again).
POST https://graph.microsoft.com/beta/teams
{
"displayName": "My Group Name",
"description": "Some description",
"template#odata.bind": "https://graph.microsoft.com/beta/teamsTemplates('educationClass')",
"owners#odata.bind": [
"https://graph.microsoft.com/beta/users('<someValidUserId>')"
]
}
I think this will be just an intermediate state and when the bugs are fixed, they will publish the new version again and this kind of creation will fail again, but if in this case the v1.0 documented way will work this wouldn't be a big problem. But being informed BEFORE there roll-out starts would be great.
This was a Microsoft issue/ bug and is currently being fixed as stated here.
My goal is simple.
I want to send an automated chat message in to a MS Teams channel using the graph API.
This seems to be beta feature of the graph API and is only avalible in the Microsoft.Graph.Beta.
I have read the docs and have been trying to follow this example:
https://learn.microsoft.com/en-us/graph/api/channel-post-messages, I have all the permissions set correct in my azure portal. I keep getting 'Unknown Error' I have tried:
var graphServiceClient = MicrosoftGraphService.GetGraphServiceClient();
var chatMessage = new ChatMessage
{
Subject = null,
Body = new ItemBody
{
ContentType = BodyType.Text,
Content = messageText
}
};
var response = await graphServiceClient.Teams["77f9c17f-54ca-4275-82d4-fff7esdacda1"].Channels["2007765c-8185-4cc7-8064-fb1b10f27e6b"].Messages.Request()
.AddAsync(chatMessage);
I have also tried to to see if I can get anything from teams:
var teams = await graphServiceClient.Teams["77f9c17f-54ca-4275-2sed4-ffsde59acda1"].Request().GetAsync();
Again all I get is Unknown error, I have used GRAPH API before to do things like get users in an organisation, so I know the genreal set up is correct.
Has anyone on the Internet somewhere in the world got this to work?! becuase its driving me crazy
Same problem here :
Everything is ok with users or groups, but I can't get anything from Teams (unknownError)
All IDs are correct and checked
Here are the authorizations I have set for the app :
Read all users' teamwork activity feed
Read all groups
Send a teamwork activity to any user
Get a list of all teams
Here is my code (based on microsoft daemon app scenario)
The access token is ok
var graphClient = new GraphServiceClient(
"https://graph.microsoft.com/beta",
new DelegateAuthenticationProvider(async (requestMessage) =>
{
requestMessage.Headers.Authorization =
new AuthenticationHeaderValue("Bearer", result.AccessToken);
}));
var chatMessage = new ChatMessage
{
Subject = "Message de test",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Contenu de test"
}
};
await graphClient.Teams["218a4b1d-84d5-48a2-97a0-023e4e4c3e85"].Channels["19:adbf8ddf37a049aa9f63a0f8ee0e8054#thread.tacv2"].Messages
.Request()
.AddAsync(chatMessage);
And the result :
Token acquired
Code: UnknownError
Inner error:
AdditionalData:
request-id: e2e433d8-cedd-4401-b5b2-6f34cf5611cf
date: 2020-03-30T12:14:15
ClientRequestId: e2e433d8-cedd-4401-b5b2-6f34cf5611cf
Edit(2020-04-01) :
No solution at the time being : there are answers to comments at the bottom of the page "Create chatMessage in a channel" in ms doc (feedback section)
It seems that applications cannot be granted the permission to send chatMessages up to now.
RamjotSingh commented on Jun 11, 2019 Contributor
#pythonpsycho1337 - As the permission table above notes, Application
only context is not supported on this API at the moment.
RamjotSingh commented on Dec 16, 2019 Contributor
Supporting application permissions is something we plan to do but we do not have a date yet.
RamjotSingh commented a day ago Contributor
We will share on Microsoft Graph Blog once we have application
permissions for this API. Since the original question for this issue
was answered. Closing it.
How can I set a team picture using Microsoft graph API?
Is there a way while provisioning Microsoft team using the automated way[Using Microsoft Graph Team API] we can set team picture icon or upload team picture icon using Microsoft graph API.
Set Team Icon can be done by the below lines of code using Patch Request with custom Content-type using plaint HttpRequest in C#
HttpClient _httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Valid_accessToken");
string graphUploadPhotoEndPoint = $"{GRAPH_ENDPOINT_1_0}/groups/{TeamsId or GroupId}/photo/$value";
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(HttpMethod.Put, graphUploadPhotoEndPoint);
Stream stream = System.IO.File.OpenRead($"{IconPath}");
HttpContent content = new StreamContent(IconeContent);
request.Content = content;
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
var response = _httpClient.SendAsync(request).Result;
string sitesRootResponse = await response.Content.ReadAsStringAsync();
Yes you can do that through the group profile photo endpoint. Each Microsoft team relies on a unified group underneath so all operations done on a group will reflect on the team.
Here is the documentation of the endpoint
I am trying to programmatically add the mention of users that are members of groups in TFS in the discussion area of work items. We were using the 1.0 version with TFS 2017 update 2 with success:
#{id.DisplayName}
However upgrading to TFS 2017 update 3 fails to send emails on the notifications. We also tried all of the "user ids" we could find on the TeamFoundationIdentitiy object for the solutions found here:
VSTS - uploading via an excel macro and getting #mentions to work
So how can we get emails for #mentions to work again in TFS 2017.3?
Update: 9/11/2018
Verified service account fails to send emails while my account running the same code will send emails for mentions:
using (var connection = new VssConnection(collectionUri, cred))
using (var client = connection.GetClient<WorkItemTrackingHttpClient>())
{
var wi = new JsonPatchDocument
{
new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/fields/System.History",
Value = $"#{id.DisplayName} <br/>"
}
};
using (var response = client.UpdateWorkItemAsync(wi, workItemId, suppressNotifications: false))
{
response.Wait();
}
}
We solved by dropping use of the WorkItemHttpClient and going back to loading the SOAP WorkItemStore as the user that submitted the changes instead of the service account. It would be nice if we could use impersonation of a user with TFS's WebApi