Here is how you can use Postman to help you develop your GraphQL API calls, which provides certain benefits:
-
Faster development of your application, so there are no headaches on how to code your POST requests, since everything is generated.
-
The username and password are already converted to a base64 encoded string, so there’s no need to store the username and password in a configuration file. Instead, you just store the the converted string, which provides extra security.
This example uses the POST method instead of GET to add an extra layer of security for the call.
-
Install Postman.
-
Open Postman and create a new request:
-
Set the method to POST.
-
Enter the URL that points to the GraphQL service endpoint:
-
-
On the Authorization tab, set TYPE to Basic Auth and then enter the authorized user’s username and password.
-
On the Body tab, select GraphQL and enter your query:
-
Click the Send button to test your query. If it’s successful, you should see the
200 OK
status and the returned JSON result at the bottom of the page. -
Generate the code by clicking on the Code link and choosing your preferred programming language (Java - Unirest in this example).