Tag: Soap UI

Deployment REST API : Uploading Zip Files #2

Deployment REST API : Uploading Zip Files #2

Following on from the previous post, we are now in a position to begin putting together the different elements and actually working out how to use the Deployment REST API to upload a Zip File programatically. As I have said on many occasions I’m most definitely not a coder, but I like to explore and often it helps me in my day job : if I can piece together a plan and show that it works, other more intelligent people can get behind it. All of that means that any code I share (and you are welcome to post a comment and I will forward it to you) is strictly for entertainment and educational purposes only.

Back to our challenge, and here is our strategy.

  1. Ask the user for a Zip File
  2. Base64 encode the Zip File
  3. Use the Authentication mechanism from last time, log the user in to the Oracle Policy Automation Hub
  4. POST the request
  5. Observe the Response in the Oracle Policy Automation Hub and in our code
  6. Debug any issues

Building the Solution

The only thing to remember is that you need a snapshot file from the Deployment page, but even I know how to display a Windows Dialog and grab the file name.

OPA Hub - Deployment REST API Get File

2. Base64 encode the Zip File, as we mentioned in the previous post.

3. Use the authentication mechanism as we did in the original post. If you are struggling with the concepts behind it, read the section about debugging further on in this article.

4. POST the Request. Nothing much to see here, except the need to instantiate all the different elements of your Visual Basic Class before you serialize the whole thing into JSON. In the image below, I’m using the Classes generated in JSONUtils and building my structure before serializing it into JSON.

OPA Hub - Dep;loyment REST API example code

The actual POST comes from the Stack Exchange code I linked to in the previous article, with a few minor modifications.

OPA Hub - Deployment REST API POST Request

5. Observing the response is pretty easy, since you should now have a new Deployment in your Oracle Policy Automation Hub. Can you guess which ones in the screenshot below came from my code?

OPA Hub - Deployment REST API Result

6. Debugging

Of course, this is going to be the place where you might spend a lot of time. And of course, the Visual Studio debugger is your friend. But part of the challenge is the lack of detail. For example, it’s good to know you have a 409 Error, or a 400 Error. But what the heck does it mean. This is where your toolset will come in very handy.

a. Use SOAP UI

SOAP UI can be used to make and debug REST API calls. The process is a little different to the SOAP calls of the past, and it is important to note that you will need to create an Authentication Profile with your Oracle Policy Automation integration user account, and check that you have a valid token before you begin. If you are new to this, the OPA Hub Website has some good news for you. In our series of articles about Web Services and integrating with other applications, we videoed a typical scenario of using SOAP UI for deployment REST API calls. Scroll down to the video labelled “REST API Services”.

b. Grab your base64

Using your Visual Studio debugger and the variable content viewer for example, grab the encoded Zip File from your session:

OPA Hub - Deployment REST API VB Debug 1

Then paste it into a REST request in SOAP UI that has a valid token, and observe the response. Way more useful and a good guide to coding your error handling in Visual Studio.

OPA Hub - Deployment REST API SOAP UI Debug 1

So what about a self-congratulatory video to finish. If you want the code, just leave a comment and I will happily provide it to you.

What’s New in Oracle Policy Automation 18A #2

What’s New in Oracle Policy Automation 18A #2

The second post in this series about What’s New in Oracle Policy Automation 18A covers the new administrative features relating to the REST API. As many readers will know, the latest versions of the product all provide a variety of interfaces that can be manipulated either using a traditional programming language (for example, in an earlier post we looked at using Microsoft Visual Studio and the REST API to review information about users, deployments and even to automate the download of a deployment ZIP file as a proof of concept), or other tools as explained below.

It is possible to use more modern tools such as curl command line tool and library to make calls and receive the JSON output. As a last resort or simply for test purposes one can always use SOAP UI. Although (naturally) we think of SOAP UI as a SOAP testing tool, it is equally at home testing REST endpoints.

What's New in Oracle Policy Automation 18A REST Project

The REST API requires the use of OAuth authentication, so you will need to set up an authentication profile and leverage it to acquire an access token. Once the token is acquired and as long as it has not expired, many calls can be made to the REST API endpoints for example for users, deployments but even (if licensed) the batch engine.

What's New in Oracle Policy Automation 18A OAuth

In the above example, the token is being accessed through Client Grant, using an integration user called integration_example. It assumes of course that this user exists on the Oracle Policy Automation Hub and has API access.

As we are discussing  What’s New in Oracle Policy Automation 18A #2, to quote from the official documentation :

Policy Automation Hub Administrators can now automate the lifecycle of end-to-end integration credentials. The OPA Hub REST API supports the management (create, view, update and delete operations) of three user types: regular users, local API client users and IDCS API client users.

As per the explanation above, the /users endpoint now supports not only normal, and API users but also an Identity Cloud Service user. In the example below, an authenticated call is made to the /users endpoint, and in the latest version this supports all the verbs you will need (GET,PUT, POST,PATCH,DELETE) to fully automate the users collection in your environment.

What's New in Oracle Policy Automation 18A Users Endpoint

The OPA Assess Method in Oracle Policy Automation Determinations #2

The OPA Assess Method in Oracle Policy Automation Determinations #2

Following from the first part of this tutorial about Oracle Policy Automation and the Determinations API, you finished the previous post with your system all ready to go for the initial use of the Web Service and the two methods. Firstly, you will use the ListGoals method to practice but also to learn an important step, then the Assess Method (Oracle Documentation). In the setup of the previous part, we deliberately ensured that anonymous access would not be possible. As a result, you will need to do some extra work before you can try out your Web Service.

Viewing the ListGoals Request

If you open the ListGoals folder in the SOAP UI interface and examine Request 1, you will see something very similar to the following:

The OPA Assess Method in Oracle Policy Automation Determinations - ListGoals


Notice that in the example, I have edited the “show-version” tag to read “true” instead of the “?” which was previously present. Many times in the following examples you will need to either edit such elements, or remove them completely if the information is not mandatory. Clicking the green triangle present in the top left hand corner of the window does not, however, get us any kind of useful response. Rather we have an error, telling us that the request we sent did not contain information sufficient to authenticate our request.

Adding the Header information for the SOAP Request

The following screenshot shows the editing you will need to do in your request (on the left hand pane) in order to proceed any further. The header information will be needed in any request you make (ListGoals or Assess methods) in this environment at the current time.

The OPA Assess Method in Oracle Policy Automation Determinations : Authentication

Once you have made these changes, save the header somewhere useful since you will need it all the time in the following examples.

Click the green triangle again. If you are still getting error messages in the right hand side pane, remember that the OPA Hub User you are authenticating with, must have permission to use the Determinations API. Check that by logging in to the Oracle Policy Automation Hub as a Hub Administrator, and viewing the details of the user in question. For ease of viewing, I have highlighted the setting that needs to be checked in order for the user to be allowed to perform the steps you are trying to do:

Viewing the Results

Hopefully, your next attempt at clicking the green triangle is more successful. Here is an example of the result you might have, if you are usin the same Project as I demonstrated in the first part of this post.

The OPA Assess Method in Oracle Policy Automation Determinations : ListGoals Response

The following annotations might be useful

  1. Notice the version information. If you set the request “show-version” to false, this section will not appear.
  2. The global entity is clearly marked.
  3. Notice this attribute does not have a readable Id. If you have forgotten to add names to your important attributes, you will see auto-generated Ids like this one. This should be your cue to go back to your Project, add a name, upload and deploy your new version.
  4. This entity has a name.
  5. The entity name, text and type are all clearly visible.

TIP : You will probably want to go back and add names for all of the attributes (race date, imminent race, and so on) and deploy that version.

What have you obtained?

The output has listed the top-level goals for the Project. In our case, there are Global and entity-level goals that can be inferred by providing the right information to perform an assessment. The ListGoals lists, as it’s name suggests, the goals you can obtain outcomes for.

Armed with this information you are ready to go further. Let’s suppose you are interested in the goal called “h_status” in my example. We can attempt to obtain some output.

Assess Method Initial Call

Our first call will be made using a very cut-down version of the complete request. Since our Project contains no Properties, no Change Points and since we are going to ask for the same level of information about all of our attributes and get a level pf outcome information that is the same, no matter whether we are receiving (whether the outcome is uncertain or certain), the request can be cut down to look like this;

The OPA Assess Method in Oracle Policy Automation Determinations : Assess Request 1

Notice the outcome section where we have asked for the values of the horse and the horse status, and the global attribute race_date which we have entered as our request input. The result, assuming you have been using the same Project, would be something like the response below.

The OPA Assess Method in Oracle Policy Automation Determinations : Assess Response 1

In this output, the following areas are highlighted :

  1. The race date is reiterated
  2. The entity instances of the horse entity are shown, each with the name and the status
  3. The attributes are inferred as you would expect

Outcome Styles and Assess Method

In this first request, you set outcome style to “value-only”. Two other choices are possible at this juncture.  Change the outcome style for the horse status to “base-attributes”, as in the example shown below.

The OPA Assess Method in Oracle Policy Automation Determinations : Assess Request 2

Upon executing the request, you will notice that the outcome has more detail. This information is very useful, since it highlights the base attributes that are needed to infer the horse status. In this case specifically, the date of the race.

The OPA Assess Method in Oracle Policy Automation Determinations : Assess Response 2

Finally, change the outcome style of the same attribute to “decision-report”. Now the output will include the tree of decisions that lead to the output:

The OPA Assess Method in Oracle Policy Automation Determinations : Assess Response 2

So far so good  – Assess Method

So it is clear that the outcome style can not only assist us in understanding which attributes are needed as input (base attributes) but also in understanding the decision that was made (decision report). In the next part of this series we will investigate other tags in the request and response.

Logo by Southpaw Projects LLC