Debugging REST API Types that mix in REST

I am curious about best practices for debugging REST API Calls via types that mix in the REST type.

Let’s say I have a type:

@rest() 
type RestCall mixes REST { 
  @rest() 
  methodName: function( 
    @rest() 
    parameter1: string, 
    ... <<<other parameters>>>
  ) : ReturnObject 
} 

When I call the RestCall.methodName(parameter1) function from the client/browser, the following happens:

  1. my client makes an API call to the C3 server with parameter1 as a payload.
  2. The C3 server processes that request via internal logic based on the @rest annotations on the type, method, and method parameters and formats a REST API call.
  3. The C3 server sends the formatted REST API Call to the appropriate endpoint as determined by the type/method/parameter annotations.
  4. The C3 server receives a response to the REST API Call.
  5. The C3 server tries to put that response into the format determined by the ReturnObject response of the function.
  6. The C3 Server returns ReturnObject and any other network status codes (200/400/500) to the browser/client.

I can debug Steps #1 and #6 very well in client-side Breakpoints, chrome developer tools, and splunk as these steps happen in the boundaries of the type system. However, I have not found a way to find more information on Steps 2-5 in Splunk or in any way. I am seeing an error that the body/payload of my api call is not in the proper format from the external endpoint, but I am struggling with where to start debugging because I don’t know how the C3 rest engine is translating my RestCall.methodName(parameter1) call into a cURL equivalent readable string.

Does anyone have any best practices to share here? Am I not using the right splunk query? Is there another way to see outbound traffic from the server?

You can enable tracing of the corresponding http request/response headers and body) in the server logs, but you need to enable the right log level on the c3.service.rest logger. You can do Cluster.setLogLevel(‘c3.service.rest’, ‘TRACE’, time-to-enable-this-level-in-seconds) and the look at the splunk logs. The logger to look for it c.s.r.RESTEngine

1 Like

Do you know of a way to find all of the different loggers available?

C3.listLoggers()

However, that doesn’t necessarily tell you what they do

Thanks Riley, C3.listLoggers() is a 7.9 command, I assume?

@ColumbusL Another typo… Server.listLoggers(), and it’s been around since at least v7.0 (that’s as far back as git history will tell me)