Question
· Jan 21

How I access a REST web service I've created?

I've created a Rest Service as described here 

Configured the webapplication as described in the previous link, and now have a URL which I call in PostMan

http://VIR-HC-DEV-01.gmmh.nhs.uk:52773/api/mgmnt/v2/parisconnect/PCRest

Which returns the JSON spec as I would expect:

{
    "swagger": "2.0",
    "info": {
        "version": "1.0.0",
        "title": "Swagger Petstore",
        "description": "A sample API to demonstrate features in the swagger-2.0 specification",
        "termsOfService": "http://swagger.io/terms/",
        "contact": {
            "name": "Swagger API Team"
        },
        "license": {
            "name": "MIT"
        }
    },
    "basePath": "/csp/healthshare/parisconnect",
    "schemes": [
        "http"
    ],
    "consumes": [
        "application/json"
    ],
    "produces": [
        "application/json"
    ],
    "paths": {
        "/Messages": {
            "get": {
                "description": "Returns all messages the system handles",
                "operationId": "Messages",
                "produces": [
                    "application/json"
                ],
                "responses": {
                    "200": {
                        "description": "A list of supported messages",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/Message"
                            }
                        }
                    }
                }
            }
        },
        "/Hello": {
            "get": {
                "description": "Says Hello",
                "operationId": "Hello",
                "produces": [
                    "text/plain"
                ],
                "responses": {
                    "200": {
                        "description": "Said hello",
                        "schema": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "Message": {
            "type": "object",
            "required": [
                "id",
                "name",
                "description"
            ],
            "properties": {
                "id": {
                    "type": "integer",
                    "format": "int64"
                },
                "name": {
                    "type": "string"
                },
                "description": {
                    "type": "string"
                },
                "tag": {
                    "type": "string"
                }
            }
        }
    },
    "host": "VIR-HC-DEV-01.gmmh.nhs.uk:52773"
}

I can use

http://localhost:52773/api/mgmnt/v2/

Which returns

[
    /*removed stuff*/
    {
        "name": "PCRest",
        "dispatchClass": "PCRest.disp",
        "namespace": "PARISCONNECT",
        "swaggerSpec": "/api/mgmnt/v2/PARISCONNECT/PCRest"
    }
]

As you can see I have two messages which are defined in impl

/// A sample API to demonstrate features in the swagger-2.0 specification<br/>
/// Business logic class defined by OpenAPI in PCRest.spec<br/>
/// Updated Jan 21, 2024 15:15:01
Class PCRest.impl Extends %REST.Impl [ ProcedureBlock ]
{

/// If ExposeServerExceptions is true, then details of internal errors will be exposed.
Parameter ExposeServerExceptions = 0;
/// Returns all messages the system handles
ClassMethod Messages() As %DynamicObject
{
    //(Place business logic here)
    Do ..%SetStatusCode("200")
    //Do ..%SetHeader(<name>,<value>)
    //Quit (Place response here) ; response may be a string, stream or dynamic object
    #dim tJson as %Library.DynamicArray
	set tJson = ##class(%Library.DynamicArray).%New()
	
    
    do tJson.%Push("{""id"":""" _1_""", ""Name"": ""Name"", ""Description"": ""Description""}")	              
    
    Quit tJson.%ToJSON()
}

/// Says Hello
ClassMethod Hello() As %Stream.Object
{
    //(Place business logic here)
    Do ..%SetStatusCode("200")
    //Do ..%SetHeader(<name>,<value>)
    //Quit (Place response here) ; response may be a string, stream or dynamic object
    quit "Hello"
}

}

How do I go about calling the Hello message using postman? I've been all over the docs specified in the above, and can't find anything and feel I'm missing something?

The following GET post in Postman returns a 404

http://VIR-HC-DEV-01.gmmh.nhs.uk:52773/api/mgmnt/v2/PARISCONNECT/PCRest/Hello

What am I doing wrong?

$ZV: IRIS for Windows (x86-64) 2021.2.1 (Build 654U) Fri Mar 18 2022 06:09:35 EDT
Discussion (6)2
Log in or sign up to continue

Hello @Andy Stobirski 

Have you created a web application? If not, You have to create a web application. Configure the necessary details such as namespace, url add your PCRest.disp in dispatch class and assign roles. Save the application and call your RESTFul api from postman.

/// Says Hello
ClassMethod Hello() As %Stream.Object
{
	return {"status":"ok","message":"working"}
}