Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Upload template gives 401 Unauthorized if Accept header is application/json #1251

Open
2 tasks done
ppazos opened this issue Feb 21, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@ppazos
Copy link
Contributor

ppazos commented Feb 21, 2024

Before reporting an issue

  • I have searched existing issues
  • I have reproduced the issue with the latest release

Environment information

JDK 11
Last docker-composer

Steps to reproduce

curl --request POST \
  --url http://localhost:8080/ehrbase/rest/openehr/v1/definition/template/adl1.4 \
  --header 'Accept: application/json' \
  --header 'Authorization: Basic ZWhyYmFzZS11c2VyOlN1cGVyU2VjcmV0UGFzc3dvcmQ=' \
  --header 'Content-Type: application/xml' \
  --cookie JSESSIONID=41E34F2B245877C78AD9D03A1276B371 \
  --data '____PASTE_OPT_HERE____'

Expected behavior

If the Accept content type is not supported, something like 406 Not Acceptable should be returned.

Actual result

401 Unauthorized is returned, but that status has nothing to do with EHRBASE not supporting the content type in the Accept header.

Also found an inconsistency: when uploading the same template twice and the second response is 409 Conflict, it actually returns a JSON response, which kinds of contradicts not supporting an Accept: application/json header. If the endpoint returns JSON, then the Accept:application/json should be accepted. Otherwise the error object should be serialized in another format, like application/xml instead of JSON.

{
	"error": "Conflict",
	"message": "Operational template with this template ID already exists: RIPPLE - Conformance Test template"
}

Further information

Note: the inconsistency for the response content type happens when there is a Prefer: return=representation header in the request. If that is not in the request, then the response error is XML.

@ppazos ppazos added the bug Something isn't working label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant