Creating a corpus via POST /corpora with Content-Type: application/json always fails with HTTP 500. The JSON handler function api:corpora-post-json references the variable $auth, but — unlike its XML counterpart — never declares it (neither as a %rest:header-param nor as a function parameter). The function therefore fails XQuery static analysis and can never execute.
The XML variant (Content-Type: application/xml) is unaffected and works correctly.
curl -u 'admin:' -X POST \
-H 'Content-Type: application/json' \
-d '{"name":"probe","title":"Probe"}' \
http://localhost:8088/api/v1/corpora
Add the Authorization header-param annotation and the $auth parameter to api:corpora-post-json, mirroring api:corpora-post-tei:
declare
%rest:POST("{$data}")
%rest:path("/v1/corpora")
%rest:header-param("Authorization", "{$auth}")
%rest:consumes("application/json")
%rest:produces("application/json")
%output:media-type("application/json")
%output:method("json")
function api:corpora-post-json($data, $auth) {
if (not($auth)) then ...
Creating a corpus via
POST /corporawith Content-Type: application/json always fails with HTTP 500. The JSON handler functionapi:corpora-post-jsonreferences the variable$auth, but — unlike its XML counterpart — never declares it (neither as a %rest:header-param nor as a function parameter). The function therefore fails XQuery static analysis and can never execute.The XML variant (Content-Type: application/xml) is unaffected and works correctly.
Add the Authorization header-param annotation and the $auth parameter to api:corpora-post-json, mirroring api:corpora-post-tei: