Zig
Zig
Microsoft Teams - List Joined Teams
See more Microsoft Teams Examples
Get the teams in Microsoft Teams that the user is a direct member of.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = try chilkat.Http.init();
defer http.deinit();
// Implements the following CURL command:
// curl -X GET https://graph.microsoft.com/v1.0/me/joinedTeams \
// -H 'authorization: Bearer ACCESS_TOKEN'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Adds the "Authorization: Bearer ACCESS_TOKEN" header.
http.setAuthToken("ACCESS_TOKEN");
const sb_response_body = try chilkat.StringBuilder.init();
defer sb_response_body.deinit();
http.quickGetSb("https://graph.microsoft.com/v1.0/me/joinedTeams", sb_response_body) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
const j_resp = try chilkat.JsonObject.init();
defer j_resp.deinit();
j_resp.loadSb(sb_response_body) catch {};
j_resp.setEmitCompact(false);
std.debug.print("Response Body:\n", .{});
std.debug.print("{s}\n", .{try j_resp.emit(alloc)});
const resp_status_code = http.getLastStatus();
std.debug.print("Response Status Code = {d}\n", .{resp_status_code});
if (resp_status_code >= 400) {
std.debug.print("Response Header:\n", .{});
std.debug.print("{s}\n", .{try http.getLastHeader(alloc)});
std.debug.print("Failed.\n", .{});
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams",
// "@odata.count": 3,
// "value": [
// {
// "id": "285c8d65-d8b5-447a-91c7-85593d50c826",
// "createdDateTime": null,
// "displayName": "Chilkat Software, Inc.",
// "description": null,
// "internalId": null,
// "classification": null,
// "specialization": null,
// "visibility": null,
// "webUrl": null,
// "isArchived": false,
// "isMembershipLimitedToOwners": null,
// "memberSettings": null,
// "guestSettings": null,
// "messagingSettings": null,
// "funSettings": null,
// "discoverySettings": null
// },
// {
// "id": "e527a8b1-5620-4dcf-9b29-a4713e9afa72",
// "createdDateTime": null,
// "displayName": "My Sample Team",
// "description": "My Sample Team\u2019s Description",
// "internalId": null,
// "classification": null,
// "specialization": null,
// "visibility": null,
// "webUrl": null,
// "isArchived": false,
// "isMembershipLimitedToOwners": null,
// "memberSettings": null,
// "guestSettings": null,
// "messagingSettings": null,
// "funSettings": null,
// "discoverySettings": null
// },
// {
// "id": "bc6ef2f4-d51e-4362-9a17-11ad3382b8ad",
// "createdDateTime": null,
// "displayName": "Sample Engineering Team",
// "description": "This is a sample engineering team, used to showcase the range of properties supported by this API",
// "internalId": null,
// "classification": null,
// "specialization": null,
// "visibility": null,
// "webUrl": null,
// "isArchived": false,
// "isMembershipLimitedToOwners": null,
// "memberSettings": null,
// "guestSettings": null,
// "messagingSettings": null,
// "funSettings": null,
// "discoverySettings": null
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
var id: [:0]const u8 = "";
var created_date_time: [:0]const u8 = "";
var display_name: [:0]const u8 = "";
var description: [:0]const u8 = "";
var internal_id: [:0]const u8 = "";
var classification: [:0]const u8 = "";
var specialization: [:0]const u8 = "";
var visibility: [:0]const u8 = "";
var web_url: [:0]const u8 = "";
var is_archived: bool = false;
var is_membership_limited_to_owners: [:0]const u8 = "";
var member_settings: [:0]const u8 = "";
var guest_settings: [:0]const u8 = "";
var messaging_settings: [:0]const u8 = "";
var fun_settings: [:0]const u8 = "";
var discovery_settings: [:0]const u8 = "";
_ = try j_resp.stringOf(alloc, "\"@odata.context\"");
_ = j_resp.intOf("\"@odata.count\"");
var i: i32 = 0;
const count_i = j_resp.sizeOfArray("value");
while (i < count_i) {
j_resp.setI(i);
id = try j_resp.stringOf(alloc, "value[i].id");
created_date_time = try j_resp.stringOf(alloc, "value[i].createdDateTime");
display_name = try j_resp.stringOf(alloc, "value[i].displayName");
description = try j_resp.stringOf(alloc, "value[i].description");
internal_id = try j_resp.stringOf(alloc, "value[i].internalId");
classification = try j_resp.stringOf(alloc, "value[i].classification");
specialization = try j_resp.stringOf(alloc, "value[i].specialization");
visibility = try j_resp.stringOf(alloc, "value[i].visibility");
web_url = try j_resp.stringOf(alloc, "value[i].webUrl");
is_archived = j_resp.boolOf("value[i].isArchived");
is_membership_limited_to_owners = try j_resp.stringOf(alloc, "value[i].isMembershipLimitedToOwners");
member_settings = try j_resp.stringOf(alloc, "value[i].memberSettings");
guest_settings = try j_resp.stringOf(alloc, "value[i].guestSettings");
messaging_settings = try j_resp.stringOf(alloc, "value[i].messagingSettings");
fun_settings = try j_resp.stringOf(alloc, "value[i].funSettings");
discovery_settings = try j_resp.stringOf(alloc, "value[i].discoverySettings");
i = i + 1;
}
}