1

I am new to SoapUI, I ran a post request in it for creating a user. It returned success code 201 (Same as Postman), which should be, but it is not showing any data under JSON tab in Response window. Where it should show some data as the request is returning data in JSON format in Postman. The response returned in the Postman is:

{
"id": 107,
"creationTime": "2017-06-23T12:55:13.870+0000",
"lastUpdateTime": "2017-06-23T12:55:13.870+0000",
"username": "Testuserr",
"name": null,
"firstname": null,
"type": null,
"avatar": null,
"mobile": null,
"office": null,
"email": null,
"enabled": false,
"_links": {
    "self": {
        "href": "http://server/...../user/107"
    },
    "consultantUser": {
        "href": "http://server/...../user/107"
    },
    "roles": {
        "href": "http://server/...../user/107/roles"
    },
    "regularRole": {
        "href": "http://server/...../user/107/regularRole"
    },
    "userSkills": {
        "href": "http://server/...../user/107/userSkills"
    },
    "experiences": {
        "href": "http://server/...../user/107/experiences"
    },
    "educations": {
        "href": "http://server/...../user/107/educations"
    },
    "assignments": {
        "href": "http://server/...../user/107/assignments"
    },
    "certificats": {
        "href": "http://server/...../user/107/certificats"
    },
    "organisation": {
        "href": "http://server/...../user/107/organisation"
    },
    "sections": {
        "href": "http://server/...../user/107/sections"
    }
}
}

Where in SoapUI it shows nothing.

enter image description here

But if am running the same request 2nd time it shows

{
   "cause":    {
      "cause":       {
         "cause": null,
         "message": "Duplicate entry 'TestName20181' for key UK_r43af9ap4edm43mmtq01oddj6'"
  },
  "message": "could not execute statement"
}

Which is same as Postman, and should be. Then what is the problem with first time?

Help me if there was anything, I was missing during execution ... thanks...

Meet
  • 84
  • 1
  • 6
  • Error message is clear; you are sending duplicate value `TestName20181` which should be unique in each request. – Rao Jun 23 '17 at 16:24
  • Please read it clearly, I have mentioned this already. JSON response is coming for duplicate entry but with unique entry, no JSON response is coming, Where it should be. – Meet Jun 24 '17 at 04:17
  • OK. May be it would be appropriate to check with your team or the service provider in this, I guess. – Rao Jun 24 '17 at 06:33
  • @Rao. I posted the Postman response (The first JSON) which it should return in SOAPUI (Ready! API!) – Meet Jun 26 '17 at 04:08
  • What do you see in the RAW response? Maybe, for some reason, SoapUI interpretes the JSON as invalid. Or maybe Postman is more tolerant toward Content Types - read as: is the accept content type correctly sent with the request (to be checked in the headers). – Matthias dirickx Jun 26 '17 at 19:35
  • in Raw, it returns 'HTTP/1.1 201 Proxy-Connection: Keep-Alive Connection: Keep-Alive Content-Length: 0 Via: 1.1 WIN-TMG-P0HEV7L Expires: 0 Date: Mon, 26 Jun 2017 04:10:51 GMT Location: http://server/...../user/110 Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache X-XSS-Protection: 1; mode=block X-Frame-Options: DENY X-Content-Type-Options: nosniff Set-Cookie: JSESSIONID=D43100F75F0E47B3615F26C7EE038572;path=/user-api;HttpOnly ' – Meet Jun 27 '17 at 07:12
  • I am impacted too. Negative test -> HTTP/1.1 400 Content-Type: application/json Transfer-Encoding: chunked Date: Fri, 31 Aug 2018 17:49:37 GMT Connection: close {"name":"First name should not be blank!!!"} Positive Test: HTTP/1.1 201 Location: http://tsbsapp63-lv.internal.shutterfly.com:8080/v2-beta/api/projects/DELL-AB-PJ-08312018-1044 Content-Length: 0 Date: Fri, 31 Aug 2018 17:52:12 GMT But postman returns json perfectly for both case, whats wrong with SOAP UI? – Bhuvanesh Mani Aug 31 '18 at 17:51

1 Answers1

1

I just figured out the difference, the content-type/media-type is blank for 201/200.Postman intelligently detects the content-type as json and displays.

I just walked to Developer desk to confirm if root cause is right and yes it is,

For 400 (negative tests): In the exception handler class, they return with media type as

    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.setContentType(MediaType.APPLICATION_JSON);

    return new ResponseEntity(errors, responseHeaders, HttpStatus.BAD_REQUEST);

But for 201/200 (positive tests): They dont set contentType, its global or default setting as per spring boot framework.

Solution#1: So DEV has to explicitly set the contentType as JSON for SOAP UI to display the json body so that we can write test scripts in it or else you will only see null response in SOAPUI though it is 200/201.

Solution#2: In your SOAP UI request, add a parameter in 'Header' as Accept = application/json. This will solve your problem without dev support.

Thanks to https://community.smartbear.com/t5/SoapUI-Pro/Change-the-reponse-from-content-type-text-html-to-text-json/td-p/39628

Screenshot

Bhuvanesh Mani
  • 1,394
  • 14
  • 23