title | description | author |
---|---|---|
Objective-C examples |
Examples Snippets generated by the api |
andrueastman |
This shows how snippets requests look like for Objective-C
GET /v1.0/me/events/AAMkAGIAAAoZDOFAAA=?$select=subject,body,bodyPreview,organizer,attendees,start,end,location HTTP/1.1
Host: graph.microsoft.com
Prefer: outlook.timezone="Pacific Standard Time"
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/events/AAMkAGIAAAoZDOFAAA=?$select=subject,body,bodyPreview,organizer,attendees,start,end,location"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"outlook.timezone=\"Pacific Standard Time\"" forHTTPHeaderField:@"Prefer"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData * data, NSURLResponse * response, NSError * nserror) {
MSGraphEvent *event = [[MSGraphEvent alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
POST /v1.0/users HTTP/1.1
Host: graph.microsoft.com
Content-type: application/json
{
"accountEnabled": true,
"displayName": "displayName-value",
"mailNickname": "mailNickname-value",
"userPrincipalName": "upn-value@tenant-value.onmicrosoft.com",
"passwordProfile" : {
"forceChangePasswordNextSignIn": true,
"password": "password-value"
}
}
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/users"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphUser * user = [[MSGraphUser alloc] init];
[user setAccountEnabled: true];
[user setDisplayName:@"displayName-value"];
[user setMailNickname:@"mailNickname-value"];
[user setUserPrincipalName:@"upn-value@tenant-value.onmicrosoft.com"];
MSGraphPasswordProfile * passwordProfile = [[MSGraphPasswordProfile alloc] init];
[passwordProfile setForceChangePasswordNextSignIn: true];
[passwordProfile setPassword:@"password-value"];
[user setPasswordProfile:passwordProfile];
NSError *error;
NSData *userData = [user getSerializedDataWithError:&error];
[urlRequest setHTTPBody:userData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData * data, NSURLResponse * response, NSError * nserror) {
//Request Completed
}];
[meDataTask execute];
PATCH /v1.0/me HTTP/1.1
Host: graph.microsoft.com
Content-type: application/json
Content-length: 491
{
"accountEnabled": true,
"businessPhones": [
"businessPhones-value"
],
"city": "city-value"
}
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphUser * user = [[MSGraphUser alloc] init];
[user setAccountEnabled: true];
NSMutableArray * businessPhonesList = [[NSMutableArray alloc] init];
[businessPhonesList addObject: @"businessPhones-value"];
[user setBusinessPhones:businessPhonesList];
[user setCity:@"city-value"];
NSError *error;
NSData *userData = [user getSerializedDataWithError:&error];
[urlRequest setHTTPBody:userData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData * data, NSURLResponse * response, NSError * nserror) {
//Request Completed
}];
[meDataTask execute];
PUT /beta/applications/{id}/synchronization/templates/{templateId} HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer <token>
Content-type: application/json
{
"id": "Slack",
"applicationId": "{id}",
"factoryTag": "CustomSCIM"
}
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/applications/{id}/synchronization/templates/{templateId}"]]];
[urlRequest setHTTPMethod:@"PUT"];
[urlRequest setValue:@"Bearer <token>" forHTTPHeaderField:@"Authorization"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphSynchronizationTemplate * synchronizationTemplate = [[MSGraphSynchronizationTemplate alloc] init];
[synchronizationTemplate setId:@"Slack"];
[synchronizationTemplate setApplicationId:@"{id}"];
[synchronizationTemplate setFactoryTag:@"CustomSCIM"];
NSError *error;
NSData *synchronizationTemplateData = [synchronizationTemplate getSerializedDataWithError:&error];
[urlRequest setHTTPBody:synchronizationTemplateData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData * data, NSURLResponse * response, NSError * nserror) {
//Request Completed
}];
[meDataTask execute];
DELETE /v1.0/me/messages/{id} HTTP/1.1
Host: graph.microsoft.com
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/messages/{id}"]]];
[urlRequest setHTTPMethod:@"DELETE"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData * data, NSURLResponse * response, NSError * nserror) {
//Request Completed
}];
[meDataTask execute];