E07793: Web Service parameter type cannot be HTTPContext
What went wrong
You're using HTTPContext type but not with CONTEXT access type. HTTPContext can only be used with :=: CONTEXT, not with QUERY, PATH, HEADER, or CONTENT.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 1331 (Why can't I bind HTTPContext to a QUERY parameter in a...)
How to fix it
- Use :=: CONTEXT for HTTPContext parameters
- Or use appropriate type for the access type
The [EXAMPLE] section below shows an HTTPContext read from a query value, then the context taken with ':=: CONTEXT' and the query read as a String.
Common causes
- HTTPContext with wrong access type (:=: QUERY, :=: PATH)
- Confusion about access type requirements
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07793: Web Service parameter type cannot be HTTPContext
#!ek9 defines module error.e07793.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 info() as GET for :/info -> //A query value is text, never the context context as HTTPContext :=: QUERY "q" <- response as HTTPResponse: TextResponse($context)
Fixed: Use HTTPContext only with CONTEXT
#!ek9 defines module error.e07793.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 info() as GET for :/info -> context as HTTPContext :=: CONTEXT <- response as HTTPResponse: TextResponse($context) search() as GET for :/search -> term as String :=: QUERY "q" <- response as HTTPResponse: TextResponse(term)
Questions and answers
These Q&A entries show E07793 and its fix: