Create team from group fails with exception - microsoft-graph-api

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.

Related

Microsoft Teams Graph API - Invalid bind property name owners in request

I'm currently having major issues with creating teams from the Graph API. I was initially trying to create teams based on groups, however I have found out today that you can now create a team without creating a group first then waiting 15 minutes to then create the team from the following link. This would make things considerably simpler.
https://learn.microsoft.com/en-us/graph/api/team-post?view=graph-rest-1.0
I am using the Microsoft.Graph SDK (v3.12.0 released 26th Aug) so replicated the http call using the SDK as follows.
var team = new Team
{
DisplayName = "My Group Name",
Description = "My Group Description",
AdditionalData = new Dictionary<string, object>()
{
{"template#odata.bind", "https://graph.microsoft.com/v1.0/teamsTemplates('educationClass')"},
{"owners#odata.bind", $"[\"https://graph.microsoft.com/v1.0/users('{usersGuid}')\"]"}
},
};
var response = await _graphClient.Teams
.Request()
.AddAsync(team);
The code above gives a:
[16:14:01 ERR] An unhandled exception has occurred while executing the request.
Status Code: BadRequest
Microsoft.Graph.ServiceException: Code: BadRequest
Message: Invalid bind property name owners in request.
If I remove the line
{"owners#odata.bind", $"[\"https://graph.microsoft.com/v1.0/users('{usersGuid}')\"]"}
from the code I get the following:
ErrorMessage : {"errors":[{"message":"A team owner must be provided when creating a team in application context."}]
Any advice would be greatly appreciated.
Thanks,
Nick
In v1.0 the owners relationship is not currently present, so you have to use the beta endpoint.
POST: https://graph.microsoft.com/beta/teams
with the following body format
{ "template#odata.bind":"https://graph.microsoft.com/beta/teamsTemplates('standard')", "displayName":"Test Team", "description":"Test description", "owners#odata.bind":["https://graph.microsoft.com/v1.0/users/{user guid}"] }
Note: the user guid should also be bare, i.e without the brackets and quotes in your example.

Devops server 2019 - Is there an REST api to add members to project and team

I was looking to add members to Project using REST API.
I was able to create project using API:
POST https://{instance}/{collection}/_apis/projects?api-version=5.0
Also, I was able to create a team in a project using REST API:
POST https://{instance}/{collection}/_apis/projects/{projectId}/teams?api-version=5.0
However, I was not able to get a REST API to add members to team and project.
Can you please help?
Devops server 2019 - Is there an REST api to add members to project
and team
For this issue,I think there is no out of box rest api to achieve it . The Members - Add rest api is currently not available for Azure DevOps Server 2019.
As a workaround ,we can track this rest api by press F12 in browser then select Network.
Sample request url :
https://collectionName/DefaultCollection/projectId/_api/_identity/AddIdentities?__v=5
Sample request body:
{
"newUsersJson": "[]",
"existingUsersJson": "[\"55b98726-c6f5-48d2-976b-xxxxxx\"]",
"groupsToJoinJson": "[\"7283653f-54b2-4ebf-86c3-xxxxxxx\"]",
"aadGroupsJson": "[]"
}
In this step ,you need to convert the name of the member you want to add and the name of the team to json, then add to the request body. Here is a case states how to convert a string to JSON in C#.
From this record ,we can get the request url and request body.
I test this with postman and can successfully add a member to a project team.
Here are two cases(case1 , case2) with similar problems. You can also refer to them.
The use voice instance in the above case is no longer available. You could submit a new one to our main forum for product suggestions. Our PM and Product Group are reviewing these suggestion regularly and considering take it as plan.
The REST API to add members to projects and team is not documented. As Hugh mentioned we can track the REST API with develop tools (press F12 in browser), however as we can see we can only use the user and team/group GUID in the request json body.
Post https://wsicads2019/DefaultCollection/{project}/_api/_identity/AddIdentities?api-version=5.0
Request Body:
{
"newUsersJson": "[]",
"existingUsersJson": "[\"55b98726-c6f5-48d2-976b-xxxxxx\"]",
"groupsToJoinJson": "[\"7283653f-54b2-4ebf-86c3-xxxxxxx\"]",
"aadGroupsJson": "[]"
}
For the specific team/groups we can use the REST APIs Projects and teams to get their GUID.
For the user, actually it's used the TeamFoundationId, the unique TeamFoundationId is automatically generated when a user is added to Azure DevOps Server. We cannot generate the ID with external tools.
So, to use that REST API, we need to get the TeamFoundationId of the specific user which you want to add it to the projects/teams.
Currently, no REST API to list TeamFoundationId of the users in Azure DevOps Server 2019, however we can get it with Client API:
Below sample for your reference to get the TeamFoundationId of a specific user: (It will also export the user list with their TeamFoundationId to userlist.txt)
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Client;
using Microsoft.TeamFoundation.Framework.Common;
using System.Linq;
using System.IO;
namespace Getuserlist
{
class Program
{
static void Main(string[] args)
{
TfsConfigurationServer tcs = new TfsConfigurationServer(new Uri("https://wsicads2019"));
IIdentityManagementService ims = tcs.GetService<IIdentityManagementService>();
TeamFoundationIdentity tfi = ims.ReadIdentity(IdentitySearchFactor.AccountName, "[DefaultCollection]\\Project Collection Valid Users", MembershipQuery.Expanded, ReadIdentityOptions.None);
TeamFoundationIdentity[] ids = ims.ReadIdentities(tfi.Members, MembershipQuery.None, ReadIdentityOptions.None);
using (StreamWriter file = new StreamWriter("userlist.txt"))
foreach (TeamFoundationIdentity id in ids)
{
if (id.Descriptor.IdentityType == "System.Security.Principal.WindowsIdentity" && id.UniqueName == "Domain\\User")
{ Console.WriteLine("[{0},{1}]", id.UniqueName, id.TeamFoundationId); }
file.WriteLine("[{0},{1}]", id.UniqueName, id.TeamFoundationId);
}
var count = ids.Count(x => ids.Contains(x));
Console.WriteLine(count);
Console.ReadLine();
}
}
}

Cant find information about acceptable response from my site to zapier app on test step (It's "Action" on my site )

I can't find information about acceptable response content or code status from my site to zapier app on test step.
I have my site on Laravel and Zapier app for this site. In my Zapier app I have an action: "Create New Project". I made my "create" according to the example. Everything works except the testing step. I tested with the following zap:
Trello -> "New card created" trigger. Test successful.
My app -> "Create new project". Test fails with We had trouble sending your test through. Could not handle special, non-standard characters. Please contact support.
Strangely, the project was created successfully. Therefore, I think the problem lies in the response from my site to zapier:
// creates/project.js
// My perform function:
perform: (z, bundle) => {
const promise = z.request({
url: `${process.env.BASE_URL}/api/folder`,
method: 'POST',
body: JSON.stringify({
title: bundle.inputData.title,
}),
headers: {
'content-type': 'application/json',
}
});
return promise.then((response) => JSON.parse(response.content));
}
//ZapierController.php
public function addFolder(Request $request)
{
// Made record to DB, and other, after this returned same data which in request
return response()->json(['title' => $request['title']]);
}
Expected result - successful test on "Test this step". Can anyone help me?
David here, from the Zapier Platform team.
I already answered your support ticket, but I figured I'd reply here in case anyone else has the same issue.
The root problem is made clear when you run zapier logs on the cli:
== Log
Unhandled error: CheckError: Invalid API Response:
- Got a non-object result, expected an object from create ("title")
What happened:
Executing creates.сFolder.operation.perform with bundle
Invalid API Response:
- Got a non-object result, expected an object from create ("title")
Your server can reply with any 2xx status code, but the output needs to be valid json. Something like {"title": "my title here"} would certainly work. Users find it more helpful to get info about the project they just created, so the name, id, etc would be even better.
As for why this surfaced as a character encoding issue, I have no clue. We plan on getting to the bottom of it though!

Create managedDevice in Intune using Graph API

I am trying to create a managed device in Intune using the following Microsoft Graph but it keeps erroring out.
I also get an error when trying to update an existing device record.
I have the appropriate scopes and my account is an Intune admin. Any suggestions?
Here is the example error I receive when trying to update using PATCH
"error": {
"code": "InternalError",
"message": "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: 7d3aea54-282a-4911-99a5-af3d2422f81a - Url: https://fef.amsua0502.manage.microsoft.com/DeviceFE/StatelessDeviceFEService/managedDevices%28%278f312966-1c51-403b-9b3a-6cf52643fa70%27%29?api-version=5017-09-07 - CustomApiErrorPhrase: ",
"innerError": {
"request-id": "7d3aea54-282a-4911-99a5-af3d2422f81a",
"date": "2017-11-02T12:16:55"
}
}
They have changed the endpoint without updating the documentation..
Use: /deviceManagement/managedDevices
It's a beta so endpoints and (more frequently) required parameters in the json object chances..
I've figured out a lot of these changes by simply looking at posts from the developer mode in a browser.
The documentation is often behind the actual implementation.
And yea this worked. sorry for late response..
Edit2:
I don't have an example to create a managed device. But this is an example on how to create an empty device configuration:
$Endpoint = "https://graph.microsoft.com/beta"
## Win10
$Win10 = [pscustomobject]#{
'#odata.type' = "#microsoft.graph.windows10GeneralConfiguration"
'description' = "standard Windows 10 Device Restriction Configuration"
'displayName' = "Win10"
}
$Win10params = #{
ContentType = 'application/json'
Headers = $Header
Body = $Win10 | ConvertTo-Json -Compress
Method = 'POST'
URI = "$Endpoint/deviceManagement/deviceConfigurations"
}
Invoke-RestMethod #Win10params
But again. Take a look at the POST in the developer tab, and then start by trying out parameters from the top. If the documentation isn't updated with the least required parameters, you will have to go through it step by step..
They have changed the endpoint without updating the documentation..
Use: /deviceManagement/managedDevices

Jira Rest API Updating an issue fixVersion give error

I'm trying to use the JIRA Rest API (version 5) to update an Issue "Fix Version" to set it to a specific version. The current issue I update has some already created bad assignee (the person assigned to it no more exist).
Using the normal Jira web interface, I am able to set the "Fix Version" to the desired value, even if the assignee is wrong.
Using the REST Issue PUT, I received an error:
assignee: "User 'username' does not exist."
My REST call look like this (using chrome Advanced Rest Client and a C# implementation):
Doing a PUT http://.../rest/api/2/issue/[issueId]/ Where [issueId] is the Id of my issue.
My payload is:
{
"update" : {
"fixVersions" : [{
"set" : [{
"name" : "Some Version"
}
]
}
]
}
}
Is it normal that I receive an error on the REST call while I can update the Issue from the web interface ?
Is there a way I can update this issue Fix Version by REST without changing the assignee ?
Here is some code to use:
client = JIRA::Client.new({:consumer_key => CONSUMER_KEY, :consumer_secret => CONSUMER_SECRET})
project = client.Project.find('SAMPLEPROJECT')
project.issues.each do |issue|
puts "#{issue.id} - #{issue.summary}"
end
issue.comments.each {|comment| ... }
comment = issue.comments.build
comment.save({'body':'My new comment'})
comment.delete

Resources