scim2
scim2 copied to clipboard
PATCH request returns HTTP Status 415
Describe the bug A PATCH request to my SCIM service returns HTTP 415 error status.
To Reproduce
The service method is defined in the same way as in the example: TestSingletonResourceEndpoint.java
@Path("{id}")
@PATCH
@Consumes({MEDIA_TYPE_SCIM, MediaType.APPLICATION_JSON})
@Produces({MEDIA_TYPE_SCIM, MediaType.APPLICATION_JSON})
public ScimResource modify(@PathParam("id") final String id, final PatchRequest patchRequest, @Context final UriInfo uriInfo) throws ScimException
{
...
}
The @PATCH
annotation is pointing to the class: com.unboundid.scim2.server.PATCH
Then the PATCH request (tested with Postman and via curl) looks as follows:
PATCH /IamScimServiceProvider/v2/Users/M0088976 HTTP/1.1
Host: host:8080
Authorization: Basic XXXXXXXXXXXXXXXXXXX==
Content-Type: application/scim+json
Accept: application/scim+json
User-Agent: PostmanRuntime/7.17.1
Cache-Control: no-cache
Postman-Token: 80d69005-dcae-428f-a833-658fd47855e3,725f6a51-4377-4d7d-9383-8f5cea822277
Host: host:8080
Accept-Encoding: gzip, deflate
Content-Length: 201
Connection: keep-alive
cache-control: no-cache
{
"schemas":
["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
"Operations": [{
"op":"remove",
"path":"emails[type eq \"work\" and value ew \"example.com\"]"
}]
}
Received response:
<h1>HTTP Status 415 – Nicht unterstützter Media-Type</h1>
<hr class="line" />
<p><b>Type</b> Status Report</p>
<p><b>Message</b> Unsupported Media Type</p>
<p><b>Beschreibung</b> The origin server is refusing to service the request because the payload is in a format not
supported by this method on the target resource.</p>
Expected behavior The service should not return HTTP 415 as the payload and Headers comply (hopefully) with the https://tools.ietf.org/html/rfc7644
Additional context
- Tested on Apache Tomcat 9.0.21
- Tested with SDK SCIM 2: Release 2.3.1 with all relevant Maven dependencies
- GET requests work fine
Check the code you are using!
If you are looking at the stuff you've posted you will see:
Content-Type: applicatiosn/scim+json
There is an additional 's' character.
Sorry that was a typo when composing the example. I have corrected it above.
It is actually throwing this error with the correct: Content-Type: application/scim+json
I was able to solve this issue by adding dependent jar files
- jersey-media-json-jackson-x.xx.jar
- jersey-entity-filtering-x.xx.jar
to the application classpath. These files provide Jersey an ability to serialize and deserialize JSON request bodies.
Another option is to add a dependency artefact to the pom.xml file:
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.xx</version>
</dependency>