Share This:

So Watson got a call. REST API.

We had heard about the guy at a local pub. He was here to take the business out of another guy... "Web Services" they called him.

That was all we knew about it, until that night.

We started following him up, according to the source the guy was not responding well. Bad Request 400.

We sent him the request exactly as stated in the documentation:

http://localhost:8008/api/cmdb/v1/instance/BMC.SAMPLE/BMC.CORE/BMC_ComputerSystem

 

But still, the guy... nothing.

 

A bad request means that the request does reach the Jetty Server, but you probably don't know what the Jetty server is anyway.

 

So first things first.

REST API is a new cool feature of ARS.

When you start ARS it will also start the REST Engine, and if you set it up correctly it will be listening for incoming requests at a port, these request will be APIs that will be resolved and replied using the same mechanism. All that magic happens because of something called Jetty, and that's all you need to know about that.

So how do you set it up correctly... well, that part I'm not so sure, but I will tell you a simple way that works:

 

1. You go an open the jetty-selector.xml file under .../Arsystem/jetty/etc/

2. Comment the first connector and uncomment the second one. So it should look like this one:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">


<Configure id="Server" class="org.eclipse.jetty.server.Server">


  <!-- This is the default, HTTPS connector. Place your keystore file in this
  directory and set your passwords, preferrably obfuscated, to configure HTTPS. -->
  <!-- <Call name="addConnector">
  <Arg>
  <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
  <Arg>
  <New class="org.eclipse.jetty.http.ssl.SslContextFactory">
  <Set name="keyStore"><Property name="jetty.home" default="." />C:\Users\Administrator\keystore</Set>
  <Set name="keyStorePassword">OBF:1tv71vnw1yta1zt11zsp1ytc1vn61tvv</Set>
  <Set name="keyManagerPassword">OBF:1tv71vnw1yta1zt11zsp1ytc1vn61tvv</Set>
  <Set name="trustStore"><Property name="jetty.home" default="." />C:\Users\Administrator\keystore</Set>
  <Set name="trustStorePassword">OBF:1tv71vnw1yta1zt11zsp1ytc1vn61tvv</Set>
  <Set name="excludeProtocols">
  <Array type="java.lang.String">
  <Item>SSLv3</Item>
  </Array>
  </Set>
  </New>
  </Arg>
  <Set name="port">8443</Set>
  <Set name="maxIdleTime">30000</Set>
  </New>
  </Arg>
  </Call> -->


    <!-- Uncomment this HTTP connector if you are using a reverse proxy that
  handles HTTPS. NOTE: Setting the forwarded property to true will process
  the X-Forwarding headers. -->
  <Call name="addConnector">
  <Arg>
  <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
  <Set name="host"><Property name="jetty.host" /></Set>
  <Set name="port"><Property name="jetty.port" default="8008" /></Set>
  <Set name="maxIdleTime">300000</Set>
  <Set name="Acceptors">2</Set>
  <Set name="statsOn">false</Set>
  <Set name="confidentialPort">8443</Set>
  <Set name="lowResourcesConnections">20000</Set>
  <Set name="lowResourcesMaxIdleTime">5000</Set>
  <Set name="forwarded">true</Set>
  </New>
  </Arg>
  </Call>


</Configure>

 

Line 10 and line 31 have the comment chars.

Also line 37 and 51 have been wiped out of the commenting brackets.

 

3. Configure the jetty.port if needed, the default is 8008, which Watson very much prefers to leave untouched.

 

So once that is completed, you have to restart ARS so that it can bring up the listeners!

After that is done, you can test your listener to make sure it is there, and you don't waste valuable time doing nothing... something that Watson likes to do on Sunday mornings, nothing.

You do not know how to check, easy.

Open up a command prompt, run:

 

netstat -nab | findstr /c:"8008"

 

If it is listening you should get something like this:

  TCP    0.0.0.0:8008           0.0.0.0:0              LISTENING

  TCP    [::]:8008              [::]:0                 LISTENING

 

Nice and tidy.

Now we need to go to the next step. POSTMAN.

This little fellow can be a burden when you live in London, but this one is a different kind of post-man.

You can download him from the wonderful internet, and make sure you get at least version 3.2.8 since I've had some issues with older versions.

Once you get that installed you open it up and you go and create a request like this one:

 

Postman 1.JPG

 

That thing in the bottom is the Token. You need that token because it will let you go and do the real APIs. So in fact it is a key to open the door to the real world of REST.

 

So now, with the Token we want to do some CMDB stuff:

 

Postman 2.JPG

 

You need to do a GET, the URL parameter can be one of multiple options. For more options I recommend reading the manual... boring!... or getting someone like Watson to do it for you.

 

Use the headers to put an Authorization there, and in the right hand side you will write AR-JWT and then you will paste the token we got on the previous call.

 

You are all set! We solved the mystery and time will tell what will happen to Web Services.