Discussions

Ask a Question

Stored Procedures with REST

Can we run stored procedures like "asi_RebuildCounters" or any custom stored procedures with current imis REST API? Is this a possibility with current API or we can expect it in the future?

REST API: Is there an endpoint to mark the attendance for the the person attending an event that has been setup in iMIS?

Hi, I am trying to find a way to mark people as attending when they appear for an event. I am hoping this would be a call where I can pass the event key and the iMIS ID of the person attending the event. The API checks if the person is registered for the current event. If yes, then mark this person as attending which also gives them a credit for attending the event. This needs to work for a cloud hosted version 20.3.44.7858. Any guidance is appreciated.
ANSWERED

How To: Use iMIS REST API to embed a virtual file path in an IQA result

This 'how to' was developed in response to an iMIS customer that is experiencing poor page load times due to overuse of included images from IQA query results. I'm posting it here hopes that it proves useful to others in the community. **The problem:** One of the really nifty things you can do with iMIS is embed images directly into a page from IQA results by injecting markup into the display column property(ies) of an IQA. Unfortunately, if an IQA returns multiple rows, or returns images that are of indeterminant size, this practice can result in very large web pages that perform poorly because they are a) huge and b) cannot take advantage of caching and other performance optimizations within the browser or our hosting environment. This problem can be managed by tightly controlling the sizes of the images included in the IQA results, but that can require a significant effort from staff and you can still wind up with problems in environments where members/users can upload new images without staff intervention. **The solution:** most iMIS iParts get around this issue by obtaining a URL path to an image from the iMIS service API. If you're developing a custom iPart that displays images from the iMIS database, you're probably already aware of how to get a virtual file path from the API, however, if you're using images with one of our more generic web parts like a QueryList, you'll need something more along the lines of what I'm posting here. **Summary:** The basic idea is pretty simple: instead of embedding the actual encoded image in the query display, we just want to embed the data the API will need in order to retrieve a file path, and then we add javascript to obtain the file path once the document is loaded. **Step 1:** Embed our API parameters in the display properties of the query. This is done from the Display tab of the IQA. Add a custom column that injects markup with data you'll need to get an image file path. In the case of an IQA with a contact BO source, we can get the member profile image, just need the party id to get the member's profile image path: Example: '<span class="image" id="my_image_prefix_' + vBoNetContactData.Id + '" ></span>' **Step 2:** Add javascript to the content record page <head> tag that scans the document for elements that match our id attribute prefix, makes the API call, and adds the image file to the document. Javascript can be added in PageBuilder under the 'Advanced' section of the page's 'Properties' tab. Example: function setImageUrls(){ const tagPrefix = 'my_image_prefix_'; // all of the <span> tags in the doc that start with our tag prefix const imageSpans = document.querySelectorAll('span[id^="my_image_prefix_"]'); // set the background image style for each tag to the correct virtual file path to the virtual file path imageSpans.forEach(function(currentValue){ const idAttr = currentValue.getAttribute("id"); const partyId = idAttr.substr(tagPrefix.length); console.log(idAttr + ", " + partyId); fetchProfileVirtualFileData(partyId, idAttr); }); } function fetchProfileVirtualFileData(partyId, idAttr) { let xhr = new XMLHttpRequest(); xhr.open('POST', "https://my.imisdomain.com/api/PartyImage/_execute", true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('RequestVerificationToken', document.getElementById("__RequestVerificationToken").value); xhr.onload = function() { let response = null; if (xhr.status === 200 || xhr.status === 201 || xhr.status === 202) { if (xhr.responseText) { var virtualFile = JSON.parse(xhr.responseText); console.log(JSON.stringify(virtualFile)); console.log(virtualFile.Result["VirtualPath"]); let virtualPath = virtualFile.Result["VirtualPath"]; if (virtualPath.startsWith('~')){ virtualPath = virtualPath.substr(1); } const imageSpan = document.getElementById(idAttr); imageSpan.style.backgroundImage = "url(" + virtualPath + ")"; } } }; xhr.send(JSON.stringify(getProfileVirtualFileRequestBody(partyId))); } function getProfileVirtualFileRequestBody(partyId){ const requestBody = { "$type": "Asi.Soa.Core.DataContracts.GenericExecuteRequest, Asi.Contracts", "OperationName": "GetProfileVirtualFile", "EntityTypeName": "PartyImage", "Parameters": { "$type": "System.Collections.ObjectModel.Collection`1[[System.Object, mscorlib]], mscorlib", "$values": [ { "$type": "System.String", "$value": partyId } ] }, "ParameterTypeName": { "$type": "System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib", "$values": [ "System.String" ] }, "UseJson": false }; return requestBody; } window.addEventListener("DOMContentLoaded", setImageUrls); Theoretically, this can be done much more succinctly via the javascript Fetch API, but I've done this example using XHR because I'm still learning the ins and outs of fetch. If anyone comes across this and wants to post an example using fetch that'd be awesome =)! Hope this helps the community! Cheers! See Also: https://developer.imis.com/reference/partyimage Base64 image encoding pros and cons: https://bunny.net/blog/why-optimizing-your-images-with-base64-is-almost-always-a-bad-idea/ https://stackoverflow.com/questions/1574961/how-much-faster-is-it-to-use-inline-base64-images-for-a-web-site-than-just-linki

Writing your own Web API service in an iMIS project

Hello I would like to write my own Web API service and make it part of the iMIS web site project. I know that it is possible with generic Web Form projects: https://docs.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms I know that this is also possible in other CMS system, such as Kentico: https://docs.kentico.com/k11/developing-websites/using-asp-net-web-api-with-kentico The logic with Kentico is simple: 1. Kentico offers a Web API REST service, just like iMIS does. 2. It means that Kentico comes with Web API preinstalled in the .NET web-forms project 3. Which means that it's easy to create your own Web API service in Kentico, you just need to configure the routing. I expect iMIS to be the same: it also offers a WebAPI REST service, which means that it probably has Web API built into the .NET web-forms project, which means it should be easy to write my own Web API service. However I did not find documentation about it. I don't really want to write the service as a separate IIS project. Is there a way to wire up Web API into a iMIS web-form project without creating a separate web project? Thank you!

Using the API to retrieve a Bearer Token - 403 Forbidden

I am trying to retrieve a bearer token from a PHP Wordpress plugin. I know that my code works because I can get a token using the [SDK Demo][1]. But whenever I try to use my real URL, I get a 403 Forbidden error. Following the instructions [here][2], I created an application user in iMIS with the remote service role. But when I use those credentials, I still get a 403 error. I am new to iMIS, so I am assuming I am just missing some setting or that I didn't apply the Remote Service role correctly. Any help is appreciated. Thanks! [1]: https://developer.imis.com/reference/api-endpoints#token [2]: https://developer.imis.com/discuss/5b28fcda45ca51000329eb31

Are parts of the site down right now?

Are parts of the site down right now? Authentication and combo order worked yesterday now aren't.

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!

REST API: How to pay for membership dues

Hi, I am looking for an explicit example on how to pay DUES subscriptions using the RESTful API. The documentation does not provide a working example. https://developer.imis.com/v1.0.1/reference/products-dues-invoices https://developer.imis.com/v1.0.1/reference/comboorder Thank you.