These docs are for v20.3.44. Click to read the latest docs for v20.3.186.

Discussions

Ask a Question
ANSWERED

Creating addresses for events

How do you create an address for an event using C#? Thanks, Julie
ANSWERED

In which table is stored event function´s notes.

I´ve realized that adding notes for an order line, such as "CERTEXAM" using REST API , it is stored in Order_Line table but NOT for events and functions. Does anyone know in which table they are stored? I´d appreciate any help. Thanks, Roberto.

Putting Event Functions via REST

Hey Jeremy, We have been testing this solution, but we noticed that we were not seeing any functions in Staff site under the Event when we are trying to create the event. End goal is to create events and its functions. Is there something we are missing? Are we POSTing in the wrong order? etc. Also, we'd like to share the entire project solution as well. What's the best way to get that to you? Post from here that we are using for reference: https://developer.imis.com/discuss/5b9987be463cea00036dffe3 "Hey Jack, Jeremy here, just wanted to give you a verbose update on your attempt to create and tie event functions to an existing event. Admittedly, it's a bit cumbersome relative to other entity updates due to the amount of structure inherent to it, but hopefully I can put you on the right path as much as possible. For event functions in particular, we'll need to chain a few calls to iMIS to ensure we've got every bit of data filled out for the application to utilize it safely throughout the various scenarios that entity might find itself in. This involves POSTing to both the Product and Product_Function endpoints prior to PUTting to the Event endpoint. You can take advantage of of the GenericEntityData contract with iMIS for the first two calls, which I'll demonstrate below as two simple REST calls to their respective endpoints - POST to /api/Product with a payload much like the one here. The important fields here to keep in mind would be the initial identity value (in this case, ANNCONF/DINNER, our new function tied to the Annual Conference event), as well as the _PRODUCTCODE, _PRODUCTMAJOR, and _PRODUCTMINOR fields, as varying representations of the aforementioned ID. Programatically, we'll also have to ensure ProductKey is a unique GUID. POST to _/api/ProductFunction/[Event ID here, such as ANNCONF] with a payload much like one here. Much like before, we'll tie this to the previously made product with the ANNCONF/DINNER identity value being passed in, as well as the _PRODUCTCODE with the same value. I've then merged a bit of the boilerplate code I mentioned prior along with some of the code you had written out utilizing our client library to create the following class that you can find here. The pertinent method begins at line 71. I've set some of the event function fields to newer values to showcase the PUT working as intended. I've neglected to add the first two POSTS as code within this class, although if you'd like me to look into some recipes or best practices when working with that kind of data, please let me know. " Current project code: using System; using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using Asi.Soa.Membership.DataContracts; using Newtonsoft.Json; using Asi.Soa.Core.DataContracts; using Asi.Soa.Events.DataContracts; namespace Ascension.Utilities.iMIS.EventCreator { public static class Program { public static HttpClient Client; static Program() { // set HTTP Client's base address to target iMIS instance scheduler/service Client = new HttpClient { //BaseAddress = new Uri("https://testapi.imis.com/Asi.Scheduler_SDKDemo/") BaseAddress = new Uri("https://customer.uspta.org/asi.scheduler_imis/") }; // address client's certificate and header values // NOTE: This causes all Server Certificates for https to be accepted without validation. // This is convenient during development with self-signed certificates or mismatched hostnames. // In production, you should use only certificates signed by a trusted CA and delete this line. ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; Client.DefaultRequestHeaders.Accept.Clear(); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // POST to the iMIS token endpoint with form-encoded data set, which should be modified to // correspond to your iMIS instance's MANAGER/RemoteService user var response = Client.PostAsync("token", new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("grant_type", "password"), new KeyValuePair<string, string>("username", "MANAGER"), new KeyValuePair<string, string>("password", "!pele1958") })).Result; // deserialize incoming JSON to Token object specified below, attach token to client's authorization // header with the 'Bearer' prefix to being making authenticated requests to iMIS Token token = JsonConvert.DeserializeObject<Token>(response.Content.ReadAsStringAsync().Result); Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken); } /// <summary> /// C# class representation of iMIS Bearer Token, used to authenticate additional requests /// </summary> internal class Token { [JsonProperty("access_token")] public string AccessToken { get; set; } [JsonProperty("token_type")] public string TokenType { get; set; } [JsonProperty("expires_in")] public int ExpiresIn { get; set; } [JsonProperty("userName")] public string UserName { get; set; } [JsonProperty(".issued")] public string Issued { get; set; } [JsonProperty(".expires")] public string Expires { get; set; } } /// <summary> /// Small example utilizing the above created and authenticated HTTP client /// </summary> /// <param name="args"></param> static void Main(string[] args) { MainAsync().GetAwaiter().GetResult(); } static async Task MainAsync() { //TEST PUT //const string id = "72492"; // known party Id //var response = await Update(id); //Console.WriteLine(response.IsSuccessStatusCode // ? $"Response: {response.Content.ReadAsStringAsync().Result}" // : $"Response: {response.StatusCode}"); //Console.ReadKey(); //CREATE PRODUCT FIRST WORKS! const string id2 = "ANNCONF/DINNER"; var response2 = await createProduct(id2); Console.WriteLine(response2.IsSuccessStatusCode ? $"Response: {response2.Content.ReadAsStringAsync().Result}" : $"Response: {response2.StatusCode}"); Console.ReadKey(); //Create EVENT WROKS!!! var responseCreate = await CreateEvent("ANNCONF"); if (responseCreate.IsSuccessStatusCode) { //CREATE EVENT WITH FUNCTIONS var response = await CreateEventFunction("ANNCONF", "DINNER"); if (response.IsSuccessStatusCode) { Console.WriteLine("Response: {0}", response.Content.ReadAsStringAsync().Result); } } } static async Task<HttpResponseMessage> Update(string id) { PersonData existingParty; var responseItem = await Client.GetAsync($"api/party/{id}"); if (responseItem.IsSuccessStatusCode) { // deserialize response to DataContract existingParty = JsonConvert.DeserializeObject<PersonData>(await responseItem.Content.ReadAsStringAsync()); } else return responseItem; // make minor update to the party existingParty.WebsiteUrl = Guid.NewGuid().ToString(); // serialize person data var serializedParty = JsonConvert.SerializeObject(existingParty, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); HttpContent httpContent = new StringContent(serializedParty, Encoding.UTF8, "application/json"); var response = await Client.PutAsync($"api/party/{id}", httpContent); return response; } static async Task<HttpResponseMessage> createProduct(string id) { GenericEntityData product = new GenericEntityData() ; product.EntityTypeName = "Product"; IdentityData function= new IdentityData(); function.EntityTypeName = "Product"; function.IdentityElements = new System.Collections.ObjectModel.Collection<string>(); function.IdentityElements.Add("ANNCONF/DINNER"); product.Identity = function; var functionCode = "ANNCONF/DINNER"; var functionMajor = "ANNCONF"; var functionMinor = "DINNER"; var productKey = new Guid("9eba2370-71eb-4876-b9e2-ea7b020d6b3c"); GenericPropertyData propertyData1 = new GenericPropertyData("PRODUCT_CODE", functionCode); GenericPropertyData propertyData2 = new GenericPropertyData("PRODUCT_MAJOR", functionMajor); GenericPropertyData propertyData3 = new GenericPropertyData("PRODUCT_MINOR", functionMinor); GenericPropertyData propertyData4 = new GenericPropertyData("ProductKey", productKey); product.Properties.Add(propertyData1); product.Properties.Add(propertyData2); product.Properties.Add(propertyData3); product.Properties.Add(propertyData4); var serializedGenericEntityData = JsonConvert.SerializeObject(product, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); HttpContent httpContent = new StringContent(serializedGenericEntityData, Encoding.UTF8, "application/json"); var response = await Client.PostAsync($"api/Product",httpContent); return response; } /// <summary> /// Async task to create event functions under a specified event /// </summary> /// <param name="eventId"></param> /// <param name="functionId"></param> /// <returns></returns> static async Task<HttpResponseMessage> CreateEvent(string eventId) { EventData newEvent = new EventData(); newEvent.Name = "ANNCONF"; newEvent.EventCode = "ANNCONF"; newEvent.EventId = "ANNCONF"; var serializedEventData = JsonConvert.SerializeObject(newEvent, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); HttpContent httpContent = new StringContent(serializedEventData, Encoding.UTF8, "application/json"); var responseEvent = await Client.PostAsync($"api/event",httpContent); if (responseEvent.IsSuccessStatusCode) { // deserialize response to DataContract newEvent = JsonConvert.DeserializeObject<EventData>(await responseEvent.Content.ReadAsStringAsync()); } if (responseEvent.IsSuccessStatusCode) { return responseEvent; } return new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest }; } /// <summary> /// Async task to create event functions under a specified event /// </summary> /// <param name="eventId"></param> /// <param name="functionId"></param> /// <returns></returns> static async Task<HttpResponseMessage> CreateEventFunction(string eventId, string functionId) { EventData existingEvent = new EventData(); var responseEvent = await Client.GetAsync($"api/event/{eventId}"); if (responseEvent.IsSuccessStatusCode) { // deserialize response to DataContract existingEvent = JsonConvert.DeserializeObject<EventData>(await responseEvent.Content.ReadAsStringAsync()); } // create new event function and add to existing event EventFunctionData newEventFunction = new EventFunctionData { Name = "Welcome Dinner", Description = "A welcome dinner for all attendees.", StartDateTime = new DateTime(2019, 5, 21, 19, 0, 0), EndDateTime = new DateTime(2019, 5, 21, 21, 0, 0), RegistrationType = RegistrationTypeData.FeeRegistrationRequired, EventFunctionId = eventId + '/' + functionId, EventFunctionCode = functionId, Status = "A" }; EventFunctionDataCollection eventFunctionDataCollection = new EventFunctionDataCollection(); eventFunctionDataCollection.Add(newEventFunction); existingEvent.Functions = eventFunctionDataCollection; //existingEvent.Functions.Add(newEventFunction); existingEvent.AdditionalAttributes = new GenericPropertyDataCollection(); // serialize event data with added function, coalesce to necessary type and update var serializedEventData = JsonConvert.SerializeObject(existingEvent, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); HttpContent httpContent = new StringContent(serializedEventData, Encoding.UTF8, "application/json"); var response = Client.PutAsync($"api/event/{eventId}", httpContent).Result; if (response.IsSuccessStatusCode) { return response; } return new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest }; } } } Thanks, Julie

Is the $type value still required?

There was some chatter about the **$type** value being optional in the later versions of the API, I assumed 20.3+. It still seems to be required in 20.3.34.2516, is that still the case? Or is it required in some of the endpoints and optional in others? Thanks.

Managing User Roles via REST

I'm curious about the best way to handle user roles in the REST API, as I've had some interesting issues trying to manage that via the User endpoint. 1) When you create a new User record, any roles in the UserData.Roles construct appear to be ignored - I tried using both the RoleName and the RoleKey in that string collection, but ultimately after the user was created, neither method assigned them the roles. 2) Additionally, I've noted that you cannot PUT to User to update those roles (or update the User record at all). Nor can you POST an existing record to User to update it, as that results in a 500 error (Service Error: Failed to create user [username]: DuplicateProviderUserKey). Based on this, it seems to me that the User endpoint can be used only to create the UserMain record, but cannot be used in any way to manage roles. Is that correct? Do we have to then use the UserRole endpoint to add/edit roles? Thanks!

Angular in iMIS

Any plans on switch from AngularJS to something newer like Angular 4, 5, 6 or even 7 in the near future?
ANSWERED

Using "In" query operator.

Could somebody please, give me an example how to use "In" operator? I would like to get a set of parties, but below sentences did not work: /api/party?partyid=in:(firstPartyId,secondPartyId) Thanks in advance.
ANSWERED

REST API: Custom Demographics Insert/Update

Is it possible to insert/update custom demographics through the REST APIs?

Asi.Soa.*.dll files for 20.3

Dear developers, is there a way to get hold off Asi.Soa.ClientServices.dll, Asi.Soa.ServiceModelEx.dll, Asi.Contracts.dll, Asi.Core.dll, Autofac.dll, Newtonsoft.Json.dll for iMIS 20.3? I would like to upgrade our client project to be compatible with iMIS 20.3 and also make use of the new SOA calls for batches etc. Best, Alex

REST API: Non-admins unable to see organization information

We are running iMIS version 20.3.30.4688 and using the REST API and SSO. I am able to get a correct access token for a non-admin user and am able to make requests as the user about their own information, however any requests to get information about their organization results in a "Does not have required permission. (O)" message from the API. If the access token is for a user that has organization admin role, the request works. If the access token is for a non-admin user the request responds with the message above. I would understand this response if we were trying to update the company, but this is just to get the company information. The endpoint I am making the request to is: GET https://isa.imiscloud.com/api/Party/:PartyId And getting the text string response: Does not have required permission. (O) I thought this may have something to do with possible permissions or visibility on the Party, but didn't find anything that would seem to fix it. Thanks! Brian