Calling endpoints and setting parameters
In this section, we will learn more about calling common endpoints and setting parameters.
Setting a URL
Let’s discuss the basic operation that every Karate API test starts with – calling a specific URL. This is achieved using the url
keyword. Since this is our initial condition, we can use the Given
keyword here:
Scenario: Checking user specific posts Given url 'https://jsonplaceholder.typicode.com/posts?userId=1'
It is important to put the URL in quotes – otherwise, you will get an error. This is due to how Karate parses the steps using regular expressions, as we saw in Chapter 1. Also, it must be in the same line as Given url
; it just did not fit here due to the limitation in line length.
Endpoint URL specification
In this first example, the endpoint URL is the first line in our scenario. This is more for demonstration purposes, as in the real world, a test is more likely...