Post 400 error for Mock "The request cannot be fulfilled due to bad syntax."

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

I have imported a OpenAPI/YAML API and trying to create a mock POST request but continue to get a 400 Bad Request error “The request cannot be fulfilled due to bad syntax”. My body for the Post objects appears fine.

Any help would be greatly appreciated!

Hi @connie2! Can I ask if you’re getting any other successful requests to run on the mock server?

Just to recap on what you need for a mock request in general:

  • A mock server added to the collection (your url var is presumably sending to that?)
  • An example added to the request (matching the method, address, etc)

I could successfully run my Get requests on the mock.

And the url var is the mock

Could you share what examples you have defined for the request?

Sue - I was actually trying to create the Post example and got this error. I have GET examples created and working. Perhaps I am not clear on how to create a POST example?

The process should be the same, if you’re able to screengrab the post example that might help - I would maybe also check the request headers in the example e.g. content type etc as I believe this can cause a bad request error…

These are our docs on creating examples but essentially you want to hit the Examples drop-down at the top right of the request builder and add one with the config you want to match:

Mocks quick start may also help

Sue- I have gone through this material yesterday. I will check again.