Postman Tutorial | Postman Crash Course for Beginners | Learn API Testing using Postman

A Postman tutorial walking you through the most important steps inside the Postman App. Begin writing API tests now!  

A Postman tutorial walking you through the most important steps inside the Postman App. Begin writing API tests now!  


RESTful APIs are everywhere nowadays but at the same time they are getting more complex to get started with: different HTTP methods, headers, cookies, dealing with file uploads or authentication with api keys, tokens, OAuth and so much more.


But before you start investing time writing code to retrieve the data the API is offering, why not test the request first to make sure everything is working as expected?


This is where the Postman App comes in! Postman allows you very quickly create a request with the required HTTP method and parameters, submit the request and easily inspect the results. Postman can help if you are developing APIs as well! I have created this course for testing engineers and well as for software developers.


Postman can help you during the development of your API as well as after the API is completed, by running tests that make sure your API is still working as intended.


In this Postman crash course for beginners, we will start exploring the features of Postman, creating request and building simple workflows. Then we will continue by writing API tests and automatically running a Postman collection by using the Postman Collection Runner.



Test a REST API with Java

Test a REST API with Java

This tutorial focuses on the basic principles and mechanics of testing a REST API with live Integration Tests (with a JSON payload).

This tutorial focuses on the basic principles and mechanics of testing a REST API with live Integration Tests (with a JSON payload).

1. Overview

The main goal is to provide an introduction to testing the basic correctness of the API – and we’re going to be using the latest version of the GitHub REST API for the examples.

For an internal application, this kind of testing will usually run as a late step in a Continuous Integration process, consuming the REST API after it has already been deployed.

When testing a REST resource, there are usually a few orthogonal responsibilities the tests should focus on:

  • the HTTP response code
  • other HTTP headers in the response
  • the payload (JSON, XML)

Each test should only focus on a single responsibility and include a single assertion. Focusing on a clear separation always has benefits, but when doing this kind of black box testing is even more important, as the general tendency is to write complex test scenarios in the very beginning.

Another important aspect of the integration tests is adherence to the Single Level of Abstraction Principle – the logic within a test should be written at a high level. Details such as creating the request, sending the HTTP request to the server, dealing with IO, etc should not be done inline but via utility methods.

2. Testing the Status Code
@Test
public void givenUserDoesNotExists_whenUserInfoIsRetrieved_then404IsReceived()
  throws ClientProtocolException, IOException {
  
    // Given
    String name = RandomStringUtils.randomAlphabetic( 8 );
    HttpUriRequest request = new HttpGet( "https://api.github.com/users/" + name );
 
    // When
    HttpResponse httpResponse = HttpClientBuilder.create().build().execute( request );
 
    // Then
    assertThat(
      httpResponse.getStatusLine().getStatusCode(),
      equalTo(HttpStatus.SC_NOT_FOUND));
}

This is a rather simple test – it verifies that a basic happy path is working, without adding too much complexity to the test suite.

If for whatever reason, it fails, then there is no need to look at any other test for this URL until this is fixed.

3. Testing the Media Type
@Test
public void
givenRequestWithNoAcceptHeader_whenRequestIsExecuted_thenDefaultResponseContentTypeIsJson()
  throws ClientProtocolException, IOException {
  
   // Given
   String jsonMimeType = "application/json";
   HttpUriRequest request = new HttpGet( "https://api.github.com/users/eugenp" );
 
   // When
   HttpResponse response = HttpClientBuilder.create().build().execute( request );
 
   // Then
   String mimeType = ContentType.getOrDefault(response.getEntity()).getMimeType();
   assertEquals( jsonMimeType, mimeType );
}

This ensures that the Response actually contains JSON data.

As you might have noticed, we’re following a logical progression of tests – first the Response Status Code (to ensure that the request was OK), then the Media Type of the Response, and only in the next test will we look at the actual JSON payload.

4. Testing the JSON Payload
@Test
public void
  givenUserExists_whenUserInformationIsRetrieved_thenRetrievedResourceIsCorrect()
  throws ClientProtocolException, IOException {
  
    // Given
    HttpUriRequest request = new HttpGet( "https://api.github.com/users/eugenp" );
 
    // When
    HttpResponse response = HttpClientBuilder.create().build().execute( request );
 
    // Then
    GitHubUser resource = RetrieveUtil.retrieveResourceFromResponse(
      response, GitHubUser.class);
    assertThat( "eugenp", Matchers.is( resource.getLogin() ) );
}

In this case, I know the default representation of GitHub resources is JSON, but usually, the Content-Type header of the response should be tested alongside the Accept header of the request – the client asks for a particular type of representation via Accept, which the server should honor.

5. Utilities for Testing

We’re going to use Jackson 2 to unmarshall the raw JSON String into a type-safe Java Entity:

public class GitHubUser {
 
    private String login;
 
    // standard getters and setters
}

We’re only using a simple utility to keep the tests clean, readable and at a high level of abstraction:

public static <T> T retrieveResourceFromResponse(HttpResponse response, Class<T> clazz)
  throws IOException {
  
    String jsonFromResponse = EntityUtils.toString(response.getEntity());
    ObjectMapper mapper = new ObjectMapper()
      .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    return mapper.readValue(jsonFromResponse, clazz);
}

Notice that Jackson is ignoring unknown properties that the GitHub API is sending our way – that’s simply because the Representation of a User Resource on GitHub gets pretty complex – and we don’t need any of that information here.

6. Dependencies

The utilities and tests make use of the following libraries, all available in Maven central:

7. Conclusion

This is only one part of what the complete integration testing suite should be. The tests focus on ensuring basic correctness for the REST API, without going into more complex scenarios,

For example, the following are not covered: Discoverability of the API, consumption of different representations for the same Resource, etc.

The implementation of all these examples and code snippets can be found over on Github – this is a Maven-based project, so it should be easy to import and run as it is.

Postman and laravel delete api

I am trying to make laravel api, getting request is all working fine but when I use delete request, it show this<a href="https://i.stack.imgur.com/rHB2g.png" target="_blank"><img src="https://i.stack.imgur.com/rHB2g.png"></a>

I am trying to make laravel api, getting request is all working fine but when I use delete request, it show this

Please help , what can I do for this.

And this is in my web.php,

Route::delete('article/{id}','[email protected]');

And in ArticleController

public function destroy($id)
{
    $article=Article::FindOrFail($id);
    if($article->delete()){
        return new ArticleResources($article);
    }
}

Learning the REST API Web Service Testing uses SOAP UI

Learning the REST API Web Service Testing uses SOAP UI

Learning the REST API Web-Service Testing uses SOAP UI. REST API Testing using SOAP UI + Industry standard REST API WebService connected to MySQL Databases for learning and practice. Complete A to Z course for learning the REST API Web-Service testing uses SOAP UI from basics to advanced concepts.

Learning the REST API Web-Service Testing uses SOAP UI

REST API Testing using SOAP UI + Industry standard REST API WebService connected to mysql DB for learning and practice

Welcome to REST API Web-Service Testing using SOAP UI tutorial.

Currently API is a booming technology it exists everywhere like Social media, Mobile platform, cloud computing etc,.
Now its a good opportunity to make promising career in API testing.

This course below topics and more:

  • What are the API & Webservices
  • How to Test the Webservices using Soap UI
  • What is Rest API
  • JSON
  • Request-Response
  • Soap UI tool
  • Path parameter
  • Query Paramter
  • HTTP status codes

This comprehensive course cover:

  • REST API web-service testing using popular soap ui tool
  • The SPECIAL thing about this course is, you will get 1 industry standard downloadable REST API web-service connected to Mysql database which can be executed on your own system without need of internet. You will know how API web-service interacts with back-end database.
  • You don't need to depend on free online API Web services available on internet for learning purpose.
  • This course is for someone who want make good career in API testing.

You don't need to have previous knowledge on WebService as course cover from basics.

By the end of this course:

  • You will know how to test REST API web-service
  • You will be having REST API web-service knowledge equivalent to industry standard experienced tester.

What you'll learn:

  • REST API WebService Concepts
  • REST API Testing methodology
  • Soap UI Tool
  • JSON

Happy Learning