E07760: only Integer, String, Date, Time, DateTime, Milliseconds, Duration, HTTPRequest and HTTPContext supported

Category: E07xxx Full resolution · Reported in phase: EXPLICIT_TYPE_SYMBOL_DEFINITION · Classification: SERVICE_INCOMPATIBLE_PARAM_TYPE · All error codes

What went wrong

A service method parameter uses an unsupported type.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 846 (Why can't I use Float as a service method parameter in EK9?)

Supported service parameter types

  • Integer, String
  • Date, Time, DateTime
  • Milliseconds, Duration
  • HTTPRequest (for full request access)

How to fix it

  1. Use supported parameter types
  2. For complex data, use HTTPRequest and parse body

See also

  • E07760: unsupported service parameter type (this error)
  • E07600: unsupported program argument type

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E07760: only Integer, String, Date, Time, DateTime, Milliseconds, Duration, HTTPRequest and HTTPContext supported

#!ek9
defines module error.e07760.bad

  defines class

    TextResponse with trait of HTTPResponse
      text as String?

      default private TextResponse()

      TextResponse()
        -> body as String
        this.text: body

      override contentType() as pure
        <- rtn as String: "text/plain"

      override content()
        <- rtn as Bytes: Bytes().withUtf8(text)

      override status() as pure
        <- rtn as Integer: 200

      default operator ?

  defines service

    Addresses for :/addresses open

      byAmount() as GET for :/amount
        ->
          //A Float cannot be bound from a URI
          amount as Float :=: QUERY "amount"
        <- response as HTTPResponse: TextResponse($amount)

Fixed: Use a type that can be bound

#!ek9
defines module error.e07760.good

  defines class

    TextResponse with trait of HTTPResponse
      text as String?

      default private TextResponse()

      TextResponse()
        -> body as String
        this.text: body

      override contentType() as pure
        <- rtn as String: "text/plain"

      override content()
        <- rtn as Bytes: Bytes().withUtf8(text)

      override status() as pure
        <- rtn as Integer: 200

      default operator ?

  defines service

    Addresses for :/addresses open

      //Integer, String, Date, Time, DateTime, Milliseconds and Duration can be bound
      search() as GET for :/{index-number}/search
        ->
          queryId as Integer :=: PATH "index-number"
          fromDate as Date :=: QUERY "from"
          span as Duration :=: QUERY "duration"
          timeOut as Millisecond :=: QUERY "time-out"
        <- response as HTTPResponse: TextResponse(`${queryId} ${fromDate} ${span} ${timeOut}`)

Questions and answers

These Q&A entries show E07760 and its fix: