0

Using javax.ws I need to create a POJO object for POST to a service. The input that I must POST:

{
  "attributes": {
    "firstname": "John",
    "surname": "Doe",
    "birthyear": 1965
  }
}

I set this up in a class below and then try to call it with:

AuditTrail auditTrail = new AuditTrail(...);

 final Response response = app.target(MY_END_POINT)
.path(auditTrailPath.toString())
.request()
.post(Entity.json(auditTrail));

But i get a HTTP error 204, No Content.

Am I doing this right ?

    public class AuditTrail implements Serializable {

        @JsonProperty("attributes")
        public HashMap<String, String> attributes;

        public AuditTrail() {
            attributes = new HashMap<String, String>();
        }

        public AuditTrail(...) {

            attributes = new HashMap<String, String>();
// Set values here...
        }

        public HashMap<String, String> getAttributes() {
            return attributes;
        }

        public void setAttributes(HashMap<String, String> attributes) {
            this.attributes = attributes;
        }
    }
Lennie
  • 1,999
  • 4
  • 27
  • 42

1 Answers1

0

Have you checked your server side? HTTP Status 204 is NOT an error response. It just say "I have received your request and processed it successfully, but there is nothing I need to send back to you in the payload of the response"

Refer to https://httpstatuses.com/204

Gelin Luo
  • 14,035
  • 27
  • 86
  • 139