We're giving away 30 tickets for FREE! Share your story, your vision, or your hustle and tell us why YOU deserve a ticket.
Apply nowWin a FREE 3 Day Ticket to FabCon Vienna. Apply now
Hi,
I'm trying to connect my workspaces to git repository through fabric rest api in c#. I'm getting 400 BadRequest without any clue what is wrong with the request.
Here is my code:
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
string baseUrl = "https://api.fabric.microsoft.com/v1/";
client.BaseAddress = new Uri(baseUrl);
var requestBody = new
{
gitProviderDetails = new
{
organizationName = "xxx",
projectName = "xxx",
gitProviderType = "AzureDevOps",
repositoryName = "xxx",
branchName = "main",
directoryName = "ProdPrimary"
}
};
// Convert the requestBody object to JSON
var json = JsonConvert.SerializeObject(requestBody);
var content = new StringContent(json, Encoding.UTF8, "application/json");
//json produced looks like this: {"gitProviderDetails":{"organizationName":"xxx","projectName":"xxx","gitProviderType":"AzureDevOps","repositoryName":"xxx","branchName":"main","directoryName":"ProdPrimary"}}
var gitResult = await client.PostAsync($"workspaces/{workspaceId}/git/connect", content);
Any idea what is wrong or where can I find any logs that would tell me what is wrong?
Thank you
what type of git repository is that? Public, Private cloud, private on-prem ?
This is a private repository in our Azure DevOps Subscription. I can manually assigned it in the portal, but we will have multiple workspace per each client so need to automate that.
This may not be supported yet. Talk to your CSAM.
Do you know which configuration is supported then? This is most basic there can be.
public github.com seems to be the only reliable one at the moment.
I'd like to test my call against that to rule out any errors in my request. Do you know what would be the code for github in gitProviderType.
No, and it looks like that you are already using the default provider (AzureDevOps). i have no experience with that. Maybe raise a Pro ticket?
For anyone else having this issue, problem was with accesstoken, this needs to be a user token and not a service token so when fetching the token you need to use GetAccessTokenForUserAsync instead of GetAccessTokenForAppAsync