Question

IFS Apps REST API and ODATA

  • 14 April 2020
  • 5 replies
  • 6192 views

Userlevel 7
Badge +21

I've been trying to understand the api calls via OData. 
For savety measures I've renamed our server instance to xyz.

So far I found out the following:
I logged on to an IFS10 environment via https://xyz:48080. I selected Entrance to Aurena for that.
I opened a new tab in Google Chrome and copied in the following
https://xyz:48080/main/ifsapplications/projection/v1/DocumentClassesHandling.svc/DocClassSet?$select=DocClass,DocName&$format=json
This returns a list of available Doc Classes and their description (json formatted).
Very nice.


Using the same URL and pasting it in FireFox (with no IFS10 running) the server returned the following:
https://xyz:48080/openid-connect-provider/login?rf=p8dCXSBiIY
The logon screen is shown. Seems logical to me. No idea what the parameter rf means, but I logged in (with a full access user id).

This resulted in:

Nice that the json format is even made readable (again I learned something here).

If I logout from Google Chrome IFS10 and request the same api information on document classes I get the same as in FireFox: login screen is shown.


My conclusion I need to establish a connection before I can request a REST api. Makes sense.
Now my question:
How do I set up such a connection, without the login screen?

The background is that I want to perform a REST api from another application. So this quesiton basically comes down to: give me an example to get results in a non IFS application from an IFS environment.

Regards,
Steve 


5 replies

Userlevel 7
Badge +21

For those that are interested, what I tried as well is that I try to create a link to IFS using PHP.

I’ve prepared a simple html page that will request which service to run (it is only rudimentary):

<form method="POST" action="ifs_service.php">
    <select id="service" name="service">
        <option value="DocumentClassesHandling">Document Classes Handling</option>
        <option value="CopyPart">Create, Update, Copy a Part</option>
        <option value="CompanyHandling">Maintain Company Info</option>
    </select>
    <br />
    <select id="fields" name="fields">
        <option value="DocClass">Document Class</option>
        <option value="DocName">Description</option>
    </select>
    <br />
    <br />
    <input type="submit" value="Request IFS Service" /> <br />
</form>

The content of ifs_service.php is as follows:

<?php
    $service = $_POST["service"];
    $fields = $_POST["fields"];
    
    /* Warning: only value DocumentClassesHandling for service works in this code */
    $curl = curl_init();
    curl_setopt_array($curl, array(
            CURLOPT_URL => "https://xyz:48080/main/ifsapplications/projection/v1/" . $service . ".svc/$metadata#DocClassSet(DocClass,DocName)",
            CURLOPT_RETURNTRANSFER => 1
    ));

    $response = curl_exec($curl);

    if($response === false)
    {
            echo 'Curl error: ' . curl_error($curl);
    }
    else
    {
            echo 'Operation completed without any errors';
    }

    print_r($response);
    echo '<br/>';

    $response = curl_exec($curl);
    $response = json_decode($response, true);
    print_r($response);
    echo '<br/>';
    
?>

When I open the html I see the following:

mantox.nl is my own site that is in no way connected to an IFS10 instance.

I leave the parameters as they are and hit the Request IFS Service button. This leads to:

So my conclusion now is that I have to logon in the ifs_service.php to IFS10 to prepare the connection and access to the api.

Regards,

Steve

Userlevel 7
Badge +21

I found the following which is closely related:

https://community.ifs.com/technology-all-about-the-nuts-and-bolts-that-make-it-work-50/aurena-authentification-and-token-831

Userlevel 7
Badge +21

I found a bit of documentation in the partner site (sorry for non IFS and partner employees). 

This states that IFS documentation on APIs is available. I quote:


This API Documentation is feasible to used by documentation generation tools to display the API, code generation tools to generate servers and clients in various programming languages, testing tools, and many other use cases. (Eg: Azure Logic Apps, Microsoft Power Apps) In a CORS enabled environment, you will be able to use the link directly. Otherwise, save the generated JSON and import it. The End point will be:

https://<Server>:<port>/int/ifsapplications/projection/v1/<name>.svc/$openapi

We recommend SOAP API and Swagger to test the JSON generated using $openapi.


However, in my opinion the /int/ is wrong (it returns): 

{"error":{"code":"MI_METADATA_NOTFOUND","message":"Metadata not found."}})

I noticed that https://<Server>:<port>/main/ifsapplications/projection/v1/<name>.svc/$openapi

returns better results.

Userlevel 7
Badge +30

I’m glad this was sorted out in the end, and I am especially glad to see you used “my” area (Docman) in your experiments. Document classes always makes people happy, is what I usually say… :)

 

Userlevel 7
Badge +21

Learned something from Daniel (IFS-er):


In UPD6 you cannot set the Compatibility Application Type.

And you do not get Basic Authentication on the “…/main/…” URLs.

 

In UPD8 you can flip it. That is the news.

In UPD6, you would have to make a copy of the DocumentClassesHandling projection, and change the category to “Integration” . (using Developer Studio)

When you deploy this new projection it will be available with the “../int/..” URL and with basic auth.


Since Update 8 is not yet available at this moment, I think I have to wait.

My available version is Update 6 and have no access to Developer Studio.

Points mentioned by Daniel tells me that my example of retrieving the document class info will not be working with some extensive changes.

Hope to update this soon with some Update 8 info.

Steve

Reply