jwebber
Posts: 8
Joined: Sun Jul 23, 2017 8:33 pm

Call Web API to validate Customer No

Tue Oct 22, 2019 10:56 pm

I have an installer where one of the screens the user enters their Customer No. I would like to do a web API call to validate the customer no to make sure it is valid before I continue with the install. Is there a way to do this within the custom actions? I saw the one to open up a URL in a browser, but that won't work for this. I can adjust the API to return what ever I need to for valid vs invalid.

Catalin
Posts: 6542
Joined: Wed Jun 13, 2018 7:49 am

Re: Call Web API to validate Customer No

Thu Oct 24, 2019 3:21 pm

Hello Jason,

Yes, I think that this might be achievable through a custom action.

I guess that your user enters the number through an Edit Box control. The edit box control has a property assigned to it. This property stores the value that is entered in the edit box.

In order to check the property that is assigned to your edit box control, you can go to "Dialogs" page, select the control and, on the right side, you can see the property's name:
EditBox.png
EditBox.png (105.78KiB)Viewed 4414 times
Now, coming back to the main question, I think that you may achieve this by using a HTTP POST request. POST is used to send data to a server to create/update a resource.

For instance, you can create a PowerShell script that uses the "Invoke-WebRequest" cmdlet to execute the POST method on a given url. For more information about this, please have a look on the "Invoke-WebRequest" Microsoft article.

Here is a sample PowerShell script:

Code: Select all

# use the AI_GetMsiProperty custom cmdlet to get the value of the property assigned to the edit box control (the customer number) and stores it in the
# $parameter variable
$parameter = AI_GetMsiProperty PROPERTY_ASSIGNED_TO_YOUR_EDITBOX

Invoke-WebRequest -Uri "<your_URL>" -Method "POST" -Body $parameter
This can be added in your project as a "PowerShellScriptInline" custom action.

Beside this, one important fact is what happens on your web server. Please keep in mind that this script only sends a POST request and wait for the return. The validation and the returned status code must be developed on the web server.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”