SoapUI调用REST创建事件接口失败,Postman正常求助
Hey there! I’ve worked with SoapUI for both SOAP and REST testing, so let’s figure out why your POST request is failing while Postman works perfectly.
The Root Cause
Looking at your SoapUI request raw content, the big red flag is that your JSON request body is missing entirely! That’s exactly why the server is throwing that "Object reference not set..." error—it’s trying to process event data that never arrived. GET requests work because they don’t require a request body, but POST needs that JSON payload to create the event.
Step-by-Step Fixes
1. Correctly Add the JSON Request Body in SoapUI
- Open your POST request in SoapUI and switch to the Request tab.
- Make sure the
Media Typedropdown is set toapplication/json(you already have theContent-Typeheader set, but this ensures SoapUI handles the body correctly). - If you don’t see a section to input JSON, right-click the request in the navigator panel and select Add Request Body.
- Paste your exact JSON content into the body editor:
{ "name": "Michalova událost", "place": "AC", "start": "2018-01-05T15:00:39.164Z", "end": "2018-01-05T16:00:39.164Z", "wholeDay": true, "repeating": "NEOPAKUJE_SE", "description": "Popis michalovy události" }
2. Verify the Raw Request Before Sending
- Switch to the Raw tab of your SoapUI request. You should now see the full request including the JSON body at the bottom (like your Postman example).
- Double-check that key headers match Postman:
Authorizationtoken is valid (yours looks fine, just note tokens expire so you might need to refresh it if it’s old)Content-Typeis set toapplication/json- Remove any unnecessary headers (like
Postman-Tokenwhich is tool-specific)
3. Fix the Content-Length Header
Your SoapUI request has a manually set Content-Length: 220, but if the JSON body length doesn’t match this, the server might fail to parse the payload. Let SoapUI calculate this automatically:
- Go to File > Preferences > HTTP Settings
- Uncheck the box for Manually set Content-Length
- This ensures the header always matches the actual size of your JSON body.
Example of a Working SoapUI Raw Request
Here’s how your request should look once fixed:
POST http://172.26.2.66/Event.Api/v1/events HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/json Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJCT0hVU0xBViIsImZhbWlseV9uYW1lIjoiRE9LT1VQSUwiLCJQT0lEIjoiZWJhMWVmNjMtNWUzNS00YTU3LTljNWMtNDY3ZmJhZmI5YTIyIiwiZXhwIjoxNTE1MTU4MTI3fQ.s5dNZxV6NME1G8rbYrsuv8sb1nMiB8z1GSVGHe3auVA Host: 172.26.2.66 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) { "name": "Michalova událost", "place": "AC", "start": "2018-01-05T15:00:39.164Z", "end": "2018-01-05T16:00:39.164Z", "wholeDay": true, "repeating": "NEOPAKUJE_SE", "description": "Popis michalovy události" }
Final Check
Once you’ve updated the request, send it again. The server should now receive the JSON payload and return a 200 OK response just like Postman does.
内容的提问来源于stack exchange,提问作者Michal Janošec

