All types of POST Requests with API Tester mobile app
Post requests are the most common types of requests that we perform on the internet and it is very useful in our day-to-day work life. These methods are those which are used to transfer data from a web browser to the server. In this article, I will teach you how to test post requests using API Tester mobile app.
Let's get started
What is API Tester?
Smartphones are becoming smarter all the time, and their use is increasing. Developers are now figuring out how to make their lives easier with smartphones. There are already many mobile apps available that eliminate the need for desktops/laptops for minor tasks. Termius, for example, is a popular SSH client that allows you to connect to servers while on the go from your mobile device.
API Tester is a mobile app that allows you to test APIs without requiring a PC. (Available on App Store, Play Store & AppGallery)
Main features of this app:
- Test any type of API - REST, GraphQL, WebSocket, SOAP, etc.
- Simply import requests and collections with cURL or files from your device. Also from other API tools like Postman, Swagger, etc.
- You can run all requests at once, save variables for later use and integrate with Shortcuts & Widgets.
- Learn more here
Types of POST Requests and How to Test Them with API Tester?
We are going to use JSONPlaceholder API for this tutorial. JSONPlaceholder is a free API for testing purposes.
Note: This API does not support file upload test requests or XML as a body type. As a result, only use the sections below as a guide.
POST with JSON Data
This type of POST request is used when you have JSON data that needs to be sent to the server. For example, if you want to create an account on your website and store the user's name, email address, and password in their database, then this is the right type of test for you. You can also use this type of test if you want to update an existing record in a database or send feedback to your customer service team.
Sending JSON data to your server is done by sending a POST request with the Content-Type: application/json header. This tells the server that you’re sending JSON data and it should be processed accordingly.
- Open the API Tester mobile app and tap the New Request or + icon in the top-right corner.
- You can rename your request by tapping ... in the top-right corner -> Rename.
- Enter the request URL. Select Raw in the Body section. Then, ensure that Content Type is set to application/json.
- Tap Post Data to write data in JSON format, then close the window by tapping the X in the top-right corner.
- It is now time to send the request. To do so, tap the run button in the upper-right corner.
- Following that, you can view the response in the Response tab. This Response tab displays the response as well as the status code, response time, and response size 🤩.
- By tapping on those metrics, you can also see response headers.
POST with Form Data
This type of POST request is used when you have form data that needs to be sent as part of your request. For example, when someone makes a purchase on your website and wants to submit their credit card information through a form with name/value pairs such as "Name" = "John Smith", "Card Number" = "24653354689", etc., then this type of test will let you simulate that behavior accurately (assuming your form has those specific fields).
send a form
The POST request with form data is used when you need to send a form as part of your request. This type of test will allow you to simulate that behavior accurately (assuming your form has the appropriate fields).
- In the Body section, select FormData. Then tap Add Param and select Text.
upload a file
When you need to upload a file as part of your request, this test will let you simulate that behavior accurately.
- To upload a file, repeat the above steps but select File instead of Text. Then you can browse your mobile file system for files.
POST with URL encoded (application/x-www-form-urlencoded)
When you need to POST data encoded as application/x-www-form-urlencoded, then this type of test will let you simulate that behavior accurately. This is common when sending data from a form on an HTML page or other client-side technology.
This is similar to FormData except that you cannot upload files and the data is URL encoded.
- Simply select the URLEncoded option in the Body section to start using it.
POST with XML
When you need to POST data encoded as XML, this test will let you simulate that behavior accurately.
- To send XML data, select application/xml as the Content Type with Raw as the Body type. Then enter XML data in the Post Data window.
POST with file upload (binary request)
This method can be used to test POST requests with binary file attachments. This is a good option if your request body requires a binary file. The disadvantages of this type are that you can only send one file per request and no other data can be sent with it.
- Select Binary from the Body section and then select and upload a file from your mobile file system.
Values are sometimes used repeatedly. For example, the same base URL in each request, API keys, and so on. What if we could create once and reuse these values elsewhere? Here is where global variables come into play. We can define variables once and then use them wherever they are needed.
Let's see how it works. Assume we use the same base URL in each request. This base URL can be saved in a global variable and later used in our requests.
- Tap on ... on top -> Global Variables.
- Tap Add Variable. Fill in the variable name in the key field (for example,
baseURL) and the value in the value field.
- Open any request and replace
API Tester is a great tool for testing API requests, as it can easily test every type of request that a desktop API tool could perform. In this article, we looked at different types of POST requests and how to run them through API Tester. If you find yourself making many POST requests to third-party APIs using cURL or collections from other API tools, there may be a better way to test your endpoints using API Tester.
LEAVE A COMMENT OR START A DISCUSSION
5 min read
Hiring Angular Developers in 2023: Insider Tips & Strategies
Does your company struggle to create a modern, high-performance, cross-platform web app? Do you desire cost-effective development without compromising future software quality? Many web development teams utilize Angular to build complicated single-page apps. Hiring Angular programmers is difficult.
8 min read
How Feature Flags Can Help You Ship Faster and Smarter?
Are you tired of long development cycles and hesitant to push new features to production? Feature flags may be the solution you're looking for. In this blog post, we'll explore how feature flags can streamline your development process, reduce the risk of errors, and give you more control over the features you release to your users. From testing new features to rolling out changes to a select group of users, feature flags can help you do it all. Keep reading to learn how you can start using feature flags in your development workflow today.