Understanding Responses


Hi there

I have just started learning RAML and I am having some difficulty understanding how to handle Responses.

To begin with I have downloaded the example api.raml file from this site: http://www.mulesoft.org/documentation/display/current/APIkit+Tutorial

.I have noticed that the Responses are added under ResourceTypes, and Collections as well as under certain verbs.
You will also notice that this particular file only records 200 responses - and only for the GET verbs.

So my confusion is twofold:
1] Where do you need to capture the Responses?
2] How do you capture all the different types of responses? 200, 400 etc

When I run my current WeatherTest project within the online API designer I get an error but it still comes back as a 200 - see this screenshot …

However when I run it from MuleStudio on my local machine I get a 400 even though I have not coded a 400 Response anywhere in the file.

Any advice or perhaps indication of an online tutorial that explains this would be appreciated.



Well it would appear that I can answer at least one part of my own question:
When you use the API Kit control in Mule Studio it automatically places responses into the Flow’s Configuration.xml file even though they were not present in the RAML.


Hi @steven_delport, that’s correct.

I’m not sure if I’m getting the other part of your question.

  • Collections and Base are 2 resourceTypes and yes, both have some responses definitions. Base for the get, and Collection for the post (200 and 201).

  • But additionally, GET verb of /sales resource, also has a response 200 (being of type Collection, will also have the inherited response for the POST).

  • /machines, is of type Base AND has the 200 response for the get defined at resource level (which means that is overriding it).

Thinking of resourceTypes as a OOP hierarchy is helpful to understand it. The raml spec covers it, but it might be tricky when just starting.
The RAML 100 tutorial, covers the “responses” concept. You can read both to get this.

I’m also working on a 200 tutorial that explains exactly what you are asking (and a couple of additional things, such as traits), but it’s on review phase (hopefully, we will have it published soon). Till then, feel free to contact and I’ll be glad to discuss and show you some examples.

Best Regards.