Problem to extract custom fields data in MS-Booking with Graph - microsoft-graph-api

Need help. We have 2 problems to extract custom fields data in MS-Booking by using Graph tool. We are near, but some records and/or data are sometimes missing when it wrong ...
On the first following command/request :
https://graph.microsoft.com/beta/bookingBusinesses/pouvtech#cegeptroisrivieres.onmicrosoft.com/appointments
PROBLEM : A lot of customer and appointments data are missing. Most of them are empty like the result below ...
{ "#odata.context": "https://graph.microsoft.com/beta/$metadata#bookingBusinesses('pouvtech%40cegeptroisrivieres.onmicrosoft.com')/appointments", "value": [ { "id": "AAMkADY2MjA3OGM3LTYwOWUtNGU5NS04YzAxLTE5NTk5MzJhN2I3OQBGAAAAAABCDbBYqWVtR5zSlJwdYN2dBwB4ZfrSVkupTZ_RUHowUU-UAAAAAAENAAB4ZfrSVkupTZ_RUHowUU-UAAALosc9AAA=", "selfServiceAppointmentId": "7e9e8039-2fe1-4369-9107-42f772503915", "additionalInformation": "<html>\r\n<head>\r\n<meta name=\"Generator\" content=\"Microsoft Exchange Server\">\r\n<!-- converted from html -->\r\n<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>\r\n</head>\r\n<body>\r\n<div>\r\n<div>\r\n<div>\r\n", "isLocationOnline": false, "onlineMeetingUrl": null, "customerId": null, "customerName": null, "customerEmailAddress": null, "customerPhone": null, "customerNotes": null, "serviceId": "b0da8ff4-aa62-4b04-ab6e-39ba3072ee4a", "serviceName": "Techniques de soins infirmiers", "duration": "PT45M", "preBuffer": "PT0S", "postBuffer": "PT0S", "priceType": "undefined", "price": 0, "serviceNotes": null, "optOutOfCustomerEmail": false, "staffMemberIds": [ "52637fe9-a068-4da1-aeed-a08cfc3b105f" ], "invoiceAmount": 0, "invoiceId": null, "invoiceStatus": "draft", "invoiceUrl": null, "invoiceDate": null, "customerLocation": { "displayName": "", "locationEmailAddress": null, "locationUri": "", "locationType": null, "uniqueId": null, "uniqueIdType": null, "address": { "type": "home", "postOfficeBox": "", "street": "", "city": "", "state": "", "countryOrRegion": "", "postalCode": "" }, "coordinates": { "altitude": null, "latitude": null, "longitude": null, "accuracy": null, "altitudeAccuracy": null } }, "start": { "dateTime": "2020-11-04T17:30:00-05:00", "timeZone": "America/New_York" }, "end": { "dateTime": "2020-11-04T18:15:00-05:00", "timeZone": "America/New_York" }, "serviceLocation": { "displayName": "En ligne", "locationEmailAddress": null, "locationUri": "", "locationType": null, "uniqueId": null, "uniqueIdType": null, "address": { "type": "home", "postOfficeBox": "", "street": "", "city": "", "state": "", "countryOrRegion": "", "postalCode": "" }, "coordinates": { "altitude": null, "latitude": null, "longitude": null, "accuracy": null, "altitudeAccuracy": null } }, "reminders": [] },
On the second following command/request :
https://graph.microsoft.com/beta/users/pouvtech#cegeptroisrivieres.onmicrosoft.com/events/AAMkADY2MjA3OGM3LTYwOWUtNGU5NS04YzAxLTE5NTk5MzJhN2I3OQBGAAAAAABCDbBYqWVtR5zSlJwdYN2dBwB4ZfrSVkupTZ_RUHowUU-UAAAAAAENAAB4ZfrSVkupTZ_RUHowUU-UAAAOTblRAAA=?$expand=singleValueExtendedProperties($filter%3Did eq 'Binary {ccb88e73-951a-4b10-bb49-e6628b8d8494} Name BookingItemAnsweredCustomQuestions')
PROBLEM : Custom fields data are sometimes missing because customer/appointments ID are missing like seen above. So, most of custom fields data are missing. We obtained 2 results on more than 100 appointments.
Can you help us ?

I believe this because singleValueExtendedProperties only works with 1-1 appointments in MS Bookings. I think you have multiple slots enabled in which case it only brings back the custom fields for the first slot in the booking. I have had the same issue and currently there is no work around I know of.

Related

MS Teams Graph API: Get all teams user(s) are apart of

I want to use the graph api to get the teams a list of users is a member/owner of. I am using this endpoint to pass the list of users, then select the properties of the group that I am interested in:
/beta/users/$filter=id+in+('user-1','user-2','user-15')$expand=transitiveMemberOf($select=id,resourceProvisioningOptions,displayName,mailNickname)&$select=id,resourceProvisioningOptions,displayName
This will return a list of groups the member is apart of, including the Teams the member is apart of (up to 15 users). It will filter the groups to only return id,resourceProvisioningOption,displayName and mailNickname.
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,resourceProvisioningOptions,displayName,transitiveMemberOf(id,resourceProvisioningOptions,displayName,mailNickname))",
"value": [
{
"id": "user-1",
"displayName": "Jeff Smith",
"transitiveMemberOf": [
{
"#odata.type": "#microsoft.graph.directoryRole",
"id": "directoryRole-1",
"displayName": null
},
{
"#odata.type": "#microsoft.graph.directoryRole",
"id": "directoryRole-2",
"displayName": null
},
{
"#odata.type": "#microsoft.graph.group",
"id": "team-id-1",
"resourceProvisioningOptions": [
"Team"
],
"displayName": "My Team 1",
"mailNickname": "MyTeam1"
},
{
"#odata.type": "#microsoft.graph.directoryRole",
"id": "directoryRole-3",
"displayName": null
},
{
"#odata.type": "#microsoft.graph.group",
"id": "team-id-2",
"resourceProvisioningOptions": [
"Team"
],
"displayName": "My Team 2",
"mailNickname": "MyTeam2"
}
]
}
]
}
Since the user is apart of Azure directory groups, those are returned, but the resourceProvisioningOptions identifies if the user is on a team. In this case - 2 teams.
Problem
When looking in the Teams App, we see that the user is actually apart of the 10 different teams.
When calling this endpoint: https://graph.microsoft.com/v1.0/users/user-1/joinedTeams we see that the user is apart of 10 teams
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams",
"#odata.count": 10,
"value": [
{
"id": "team-id-1",
"createdDateTime": null,
"displayName": "Team 1",
"description": "Team1",
"internalId": null,
"classification": null,
"specialization": null,
"visibility": null,
"webUrl": null,
"isArchived": false,
"isMembershipLimitedToOwners": null,
"memberSettings": null,
"guestSettings": null,
"messagingSettings": null,
"funSettings": null,
"discoverySettings": null,
"summary": null
},
{
"id": "team-id-2",
"createdDateTime": null,
"displayName": "Team 2",
"description": "Team2",
"internalId": null,
"classification": null,
"specialization": null,
"visibility": null,
"webUrl": null,
"isArchived": false,
"isMembershipLimitedToOwners": null,
"memberSettings": null,
"guestSettings": null,
"messagingSettings": null,
"funSettings": null,
"discoverySettings": null,
"summary": null
},
...
{
"id": "team-id-10",
"createdDateTime": null,
"displayName": "Team 3",
"description": "Team3",
"internalId": null,
"classification": null,
"specialization": null,
"visibility": null,
"webUrl": null,
"isArchived": false,
"isMembershipLimitedToOwners": null,
"memberSettings": null,
"guestSettings": null,
"messagingSettings": null,
"funSettings": null,
"discoverySettings": null,
"summary": null
}
]
}
Questions:
Is there another endpoint that I can use to pass a list of users and get the teams they are owner/member of?
Why is the data different between endpoints
I am trying to avoid calling the /joinedTeams endpoint due to number of users and rate limiting.
You could use the /joinedTeams endpoint, but also put those calls in a batch to MS Graph.
See: https://learn.microsoft.com/en-us/graph/json-batching
This would allow you to send a batch of 20 (i think) requests in one call to the graph making it much faster and less likely to be throttled.

Filter contacts in outlook API using startswith()

I am trying to get a list of contacts that are filtered by email address from Microsoft Outlook API (Contact API). The url I am using for the request is:
https://outlook.office.com/api/v2.0/me/contacts/?$filter=EmailAddresses/any(email: startswith(email/Address,'ab'))
The filter property $filter=EmailAddresses/any(email: email/Address eq 'ab') is working fine.
Here EmailAddresses field is a list containing name, address fields.
UPDATE
Original response :
{
"#odata.context": "https://outlook.office.com/api/v2.0/$metadata#Me/Contacts",
"value": [
{
..................................
..................................
"DisplayName": "Abhishek R",
"GivenName": "Abhishek",
"Initials": null,
"MiddleName": null,
"NickName": null,
"Surname": "R",
"Title": null,
"YomiGivenName": null,
"YomiSurname": null,
"YomiCompanyName": null,
"Generation": null,
"ImAddresses": [],
"JobTitle": null,
"CompanyName": null,
"Department": null,
"OfficeLocation": null,
"Profession": null,
"BusinessHomePage": null,
"AssistantName": null,
"Manager": null,
"HomePhones": [],
"MobilePhone1": null,
"BusinessPhones": [],
"SpouseName": null,
"PersonalNotes": null,
"Children": [],
"EmailAddresses": [
{
"Name": "abhishek#gmail.com",
"Address": "abhishek#gmail.com"
},
{
"Name": "abcdef#gmail.com",
"Address": "abcdef#gmail.com"
}
],
"HomeAddress": {},
"BusinessAddress": {},
"OtherAddress": {}
}
]
}
The response I got is:
{
"error": {
"code": "ErrorInvalidUrlQueryFilter",
"message": "The query filter contains one or more invalid nodes."
}
}
Looking for a solution to this.

how to read json within json in ios

i have the being fetched, i need to read whats inside data under sources
"id": "cus_7nDkZw63KvTuy5",
"object": "customer",
"account_balance": 0,
"created": 1453839669,
"currency": "usd",
"default_source": "card_17XdJE2eZvKYlo2CBNnle4YM",
"delinquent": false,
"description": null,
"discount": null,
"email": "someone#example.com",
"livemode": false,
"metadata": {
},
"shipping": null,
"sources": {
"object": "list",
"data": [
{
"id": "card_17XdJE2eZvKYlo2CBNnle4YM",
"object": "card",
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"customer": "cus_7nDkZw63KvTuy5",
"cvc_check": "pass",
"dynamic_last4": null,
"exp_month": 12,
"exp_year": 2016,
"funding": "credit",
"last4": "4242",
"metadata": {
},
"name": "someone#example.com",
"tokenization_method": null
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/customers/cus_7nDkZw63KvTuy5/sources"
},
"subscriptions": {
"object": "list",
"data": [
],
"has_more": false,
"total_count": 0,
"url": "/v1/customers/cus_7nDkZw63KvTuy5/subscriptions"
}
}
Try this code you will get array
[[[[result objectForKey:#"sources"] objectForKey:#"data"] objectAtIndex:0] objectForKey:#"country"];
you will get US as answer.

Remove the certain properties of objects from the json document response Swagger for REST api

Hi I am using swagger for documentation of my RESTful web service. wanted to know is there any way to remove the certain properties of objects from the json document response? I mean there are lots of properties that swagger gives for my method param objects and response model (e.g. notes, defaultValue, allowableValue, internalDescription etc.) that are not required for me and are null due to that the response is not much readable
For method params:
"parameters": [
{
"name": "someName1",
"description": null,
"notes": null,
"paramType": "path",
"defaultValue": null,
"allowableValues": null,
"required": true,
"allowMultiple": false,
"paramAccess": null,
"internalDescription": null,
"wrapperName": null,
"dataType": "string",
"valueTypeInternal": null
},
{
"name": "someName2",
"description": null,
"notes": null,
"paramType": "query",
"defaultValue": null,
"allowableValues": null,
"required": true,
"allowMultiple": false,
"paramAccess": null,
"internalDescription": null,
"wrapperName": null,
"dataType": "string",
"valueTypeInternal": null
}
],
-=============================================================================
For response model classes
"SomeResponseClass": {
"required": false,
"name": null,
"id": "SomeResponseClass",
"properties": {
"instanceVariable1": {
"required": false,
"name": null,
"id": null,
"properties": null,
"allowableValues": null,
"description": null,
"notes": null,
"access": null,
"default": null,
"additionalProperties": null,
"items": null,
"uniqueItems": false,
"type": "Date"
},
"instanceVariable2": {
"required": false,
"name": null,
"id": null,
"properties": null,
"allowableValues": null,
"description": null,
"notes": null,
"access": null,
"default": null,
"additionalProperties": null,
"items": null,
"uniqueItems": false,
"type": "double"
}
}
your JSON mapper is not configured to ignore null properties. You can easily address this as follows:
#Provider
#Produces(MediaType.APPLICATION_JSON)
public class JacksonJsonProvider extends JacksonJaxbJsonProvider {
private static ObjectMapper commonMapper = null;
public JacksonJsonProvider() {
if(commonMapper == null){
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
commonMapper = mapper;
}
super.setMapper(commonMapper);
}
}
Add this mapper to your scanning properties in the web.xml and the nulls will be gone.

How do you grab a key/value pair from an array of hashes in ruby?

I have an array of hashes (or atleast I think they are hashes) and I need to pull out the ID for each of them. I'm sure ruby has some quick way of doing this ... I just can't figure it out.
I don't want to iterate through the arrays and build a new one.
[
[
{
"bio": "I am a tech geek who loves starting up companies. While I was in college, I founded Squeeze My Tees",
"business_name": "Rounded Development",
"city": "",
"created_at": "2012-04-22T18:07:44Z",
"first_name": "Brian",
"id": 1,
"industry": "Entertainment",
"last_name": "Weinreich",
"lat": null
},
{
"access_token": null,
"bio": null,
"business_name": null,
"city": null,
"created_at": "2012-04-23T13:56:35Z",
"email": "test#jambo.com",
"first_name": "asdad",
"id": 2,
"industry": null,
"last_name": "ddfs",
"lat": null,
"linkedin_id": null,
"linkedin_url": null,
"lng": null,
"position": null,
"professional_headline": null,
"state": null,
"street": null,
"updated_at": "2012-04-23T13:56:35Z"
},
{
"access_token": null,
"bio": null,
"business_name": null,
"city": null,
"created_at": "2012-04-23T13:56:39Z",
"email": "tesasdat#jambo.com",
"first_name": "fdsd",
"id": 3,
"industry": null,
"last_name": "asdgw",
"lat": null,
"linkedin_id": null,
"linkedin_url": null,
"lng": null,
"position": null,
"professional_headline": null,
"state": null,
"street": null,
"updated_at": "2012-04-23T13:56:39Z"
},
{
"access_token": null,
"bio": null,
"business_name": null,
"city": null,
"created_at": "2012-04-23T13:56:44Z",
"email": "asdsad#jambo.com",
"first_name": "ewtrwef",
"id": 4,
"industry": null,
"last_name": "dfd",
"lat": null,
"linkedin_id": null,
"linkedin_url": null,
"lng": null,
"position": null,
"professional_headline": null,
"state": null,
"street": null,
"updated_at": "2012-04-23T13:56:44Z"
}
]
]
To pull out just the IDs you can do this:
the_IDs = array_of_hashes.collect { |single_array| single_array["id"] }
Obviously you can use less verbose variable names, they're just for illustration. But the idea is that you can loop through an array and collect whatever the block returns. In this case, you keep getting an ID returned, and the_IDs will just be an array of what was collected.

Resources