0

I am trying to create a basic HelloWorld REST API in PolicyCenter. I am getting an Internal Server Error from the GET /apis's endpoint (from the com.guidewire.pl.rest.docs.ApiListGenerator) and my new endpoint returns 404 Not Found. I am not sure what is missing and I don't see any clues in the logs. Any hints are welcome.

GET http://localhost:8180/pc/rest/apis

{
  "status": 500,
  "errorCode": "java.lang.IllegalArgumentException",
  "cause": {
    "class": "java.lang.IllegalArgumentException",
    "message": "Keys in JsonObject cannot be null"
  },
  "stackTrace": [
    "gw.api.json.JsonObject.validateKey(JsonObject.java:898)",
    "gw.api.json.JsonObject.put(JsonObject.java:849)",
    "com.guidewire.pl.rest.docs.ApiListGenerator.lambda$createApiListJson$2(ApiListGenerator.java:37)",
    "java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)", 
    ...

GET http://localhost:8180/pc/rest/helloworld

{ 
  "status": 404,
  "errorCode": "gw.api.rest.exceptions.NotFoundException", 
  "userMessage": "No resource was found at path /helloworld"
}

[modules\configuration\gsrc\myorg\pc\integration\restapi\helloworld\HelloWorldHandler.gs]

package myorg.pc.integration.restapi.helloworld    

class HelloWorldHandler {

  public function getHelloWorld() : String {
    return 'Hello, World!'
  }

}

[modules\configuration\config\integration\apis\myorg\pc\helloworld\helloworld-1.0.swagger.yaml]

swagger: "2.0"
info:
  version: "1.0"
  title: "Hello World API"
x-gw-apihandlers:
  - myorg.pc.integration.restapi.helloworld.HelloWorldHandler
paths:
  /helloworld:
    get:
      summary: "Says 'Hello World'"
      description: "Says 'Hello World'"
      operationId: getHelloWorld
      produces:
        - text/plain
      responses:
        '200':
          description: |
            Successful operation
          schema:
            type: string

[modules\configuration\config\integration\apis\published-apis.yaml]

apis:
- name: myorg.pc.helloworld.helloworld-1.0
defaultTemplate:
- name: gw.pl.framework.dev_template-1.0
Andreas Warberg
  • 542
  • 6
  • 12

2 Answers2

5

I'm glad to see you've resolved your issue, but I wanted to bring to your attention that the product documentation has been updated to include extensive documentation on this topic. If you go to the Guidewire Docs from the Guidewire Community and search for "Configuring REST APIs", you will find comprehensive docs on topics such as how to build mappers and updaters which map to and from request/response payloads to Guidewire types with minimal or no code required, how to manage authentication, how to perform pre and post processing via the IRestDispatchPlugin dispatch plugin, best practices around logging, how to localize your response payloads, and much more.

Domenick Doran
  • 261
  • 1
  • 7
0

After some digging I was able to find the documentation on the Swagger format, which mentioned basePath as a required property. After adding this, my API started working (with a different URL).

Andreas Warberg
  • 542
  • 6
  • 12