1/59
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is the main challenge in passing data in REST compared to SOAP?
REST gives you more flexibility but requires you to manually manage data formats and parameter passing, unlike SOAP which has automatic structuring.
How is data passed in SOAP?
Through structured XML in the request/response body, often including method names and typed parameters.
What does REST not assume about data?
REST does not assume any specific data format (e.g., XML, JSON), so you must define and manage it yourself.
Why can't we use plain text REST calls for complex operations?
Plain text doesn’t handle multiple or structured parameters well — it’s unclear how to interpret the data.
what does verbose mean?
using or containing more words than necessary
what are 3 major problems with REST?
no support for operations that return results and accept arguments
no way to distinguish multiple arguments from complex single values
no built-in support for structured data
Difference between SOAP and REST, with topic categories:
data format
built-in method names
structured data handling
verbose
easy for simple text
easy for structured arguments
What are the main parameter types used in REST?
Query - To filter/sort resources
Form - form web forms via POST
Path - to identify resources
Header - for meta-info (e.g., tokens)
(rarely) Matrix parameters.
What are query parameters?
Key-value pairs appended to the URL after a ?
, e.g., ?colour=red
.
Where are form parameters located?
In the body of a POST/PUT request, formatted as key=value&key2=value2
.
What are path parameters?
Values embedded directly in the URI path, e.g., /fruit/red/apple
.
What are header parameters used for?
Metadata like auth tokens or content type, passed in HTTP headers.
Are all MIME type + HTTP method + parameter combinations valid?
No. Some combinations are disallowed or considered bad practice — stick to common patterns.
Best practices for allowable combinations for paths
summary for REST tools to pass data
How do you bind query parameters in Spring Boot?
Using @RequestParam
in your controller method.
How do you customize the query parameter name?
@RequestParam(name = "customName")
.
How do you make a query parameter optional?
Use @RequestParam(required = false)
.
How do you assign a default value to a query parameter?
@RequestParam(defaultValue = "default")
.
How do you collect all query parameters into a map?
@RequestParam Map<String, String> allParams
.
How do you handle multiple values for one query parameter?
Use @RequestParam List<String> items
and pass values like items=a,b,c
.
How does a client send query parameters in Java?
By appending them to the URL:
java
new URI("http://.../path?x=5&y=7")
Where are form parameters sent?
In the body of a POST or PUT request, formatted as key=value
.
What header must be set for Spring to treat parameters as form data?
Content-Type: application/x-www-form-urlencoded
What annotation is used in Spring Boot to read form parameters?
@RequestParam
, same as for query parameters.
How many form parameters can you have?
As many as needed — just add more @RequestParam
parameters.
How does a client send form parameters?
Include a formatted string in the body and set the correct header.
How are path parameters defined in Spring Boot?
Using curly braces in the mapping and @PathVariable
.
Can parameter names in the URI differ from variable names in Java?
Yes, use @PathVariable("name")
.
Can you change the order of parameters in the URL and in the method?
Yes — match by name, not order.
How do you make a path parameter optional?
@PathVariable(name = "param", required = false)
.
Why is it risky to leave out path parameters in the middle of a URL?
It can cause ambiguity — the server may misinterpret which value goes with which parameter.
What's the fix for ambiguous paths?
Use labelled segments like /fruit/lemon/colour/yellow
.
How do you access all path parameters in a map?
@PathVariable Map<String, String> pathParams
.
How does a client include path parameters?
By inserting them directly into the URI path:
java
new URI("http://.../simple-path/5/6")
How do you read a header in Spring Boot?
Using @RequestHeader("headerName")
.
How do you make a header optional?
Add required = false
or defaultValue
.
How do you read all headers into a map?
Use @RequestHeader Map<String, String>
.
What is the HttpHeaders
class used for?
It gives access to standard headers like content type, and you can still use .get("customHeader")
.
How do you access all values of a multi-valued header?
Use @RequestHeader MultiValueMap<String, String>
.
How does a client set headers in Java?
Use .header("Header-Name", "value")
when building the request.
How do you read body content in Spring Boot?
use @RequestBody
.
Can you have more than one @RequestBody
parameter?
❌ No — only one per method.
How do you make a body parameter optional?
@RequestBody(required = false)
What's the most common use for @RequestBody
?
Sending structured data like JSON, mapped to a Java object.
What happens if no @RequestBody
is present and it's required?
Spring will throw a 400 (Bad Request) error.
How does Spring convert JSON into a Java object?
Using the Jackson library (automatically if types match).
Why are there multiple parameter passing mechanisms in REST?
Because not all mechanisms are equally capable, HTTP doesn't support all combinations, and there are best practices for choosing the right one based on context
What type of parameter is best for hierarchical navigation in REST?
Path Parameters
What is the recommended way to filter data in REST?
Use query parameters for filtering.
How many body parameters can a REST method have?
1
Which parameter type is best suited for structured data like JSON?
Body Parameters
What does the 'produces' attribute specify in a REST method?
The content type of the data returned in the response body.
What does the 'consumes' attribute specify in a REST method?
The content type of the data accepted in the request body.
Can a method consume multiple content
Yes, by listing them in the 'consumes' attribute.
What is the purpose of a maturity model?
To assess how well processes are defined, managed, and optimized in software development
What are the five levels of the CMM model?
Initial, Repeatable, Defined, Managed, Optimizing.
What are the four levels of the Richardson Maturity Model?
Level 0: Single Endpoint, Level 1: Multiple URIs, Level 2: Use of HTTP verbs, Level 3: Hypermedia Controls (HATEOAS).
What is the risk of skipping REST maturity levels?
Clients become tightly coupled to URI structure, making it hard to evolve the API.
What HTTP method can be used to support HATEOAS?
OPTIONS, although Spring Boot usually uses enhanced GET responses for this.