Documentation

Did you find this helpful?

Execute PlayFab API Via Postman

Postman Overview:

Knowing how to manually call the Web API methods is invaluable when you are trying to integrate PlayFab with your game. If a function isn’t working out quite how you expect, being able to call it in a tool that shows you the specific response data and any error messages is a powerful way to debug those calls. There are a number of tools out there that make it easy to interact directly with a Web API, but one that we really like is the Postman Chrome plugin.

This document will guide you through setting up and using Postman.

Disclaimer:

Postman is an HTTP Request tool useful to intermediate and advanced users. You should be very familiar with the topics covered in our getting started guide.

Initial Setup:

  1. Get Google Chrome.
  2. Get Postman, the free Chrome plugin. After you have Postman, you should see a similar screen:
    Postman_Blank.png#asset:374
  3. Download our Postman JSON collection (right-click, Save link as...), Click Import (on the top, black bar), and drag the saved json file into Postman:
    Postman_Import.png#asset:375
  4. Add your environment variables.

    Postman environments are a way to save key-value pairs which can be automatically injected into any portion of the HTML call. If you have a look through our collection, you will see {{____}} variables in most of them. These act as a time saver as well as an easy way to switch between different environments

    PlayFab Environment Variables:

    • {{TitleId}} - the unique identifier that corresponds to your PlayFab title. Found in the GameManager>Settings.
    • {{SecretKey}} - Found in the GameManager>Settings and used to authenticate Server API calls.
    • {{SessionTicket}} - Provided in response to any successful login Call. This  is used to authenticate most Client API calls.
    • {{PlayFabId}} - Provided in response to any successful login Call.
    • {{CharacterId}} - Returned from GetAllUsersCharacters
    • {{PrimaryCatalogName}} - Found in the GameManager>Economy>Catalogs
  1. If you already have an account, select Client\LoginWithPlayFab (from the left hand Postman menu), update the body JSON with your credentials (or - highly recommended - add them as {{}} variables and use that) and hit Send

    -OR-

    Create a new player account by selecting Client\RegisterPlayFabUser, (from the left hand Postman menu), update the body JSON with your credentials as above, and hit Send.

    In either case, after sending the request you should receive a code 200 (success) response, with a fresh SessionTicket

    Note: PlayFab SessionTickets will expire after 24hrs. After that point, you will need to re-authenticate and update your environment variable.
  2. Copy your SessionTicket and paste into the corresponding environment variable. Postman also provides a convenient shortcut to this - just select the full text of the ticket (everything in the quote marks), right click, select “Set: [Environment]” for the environment you created to store your variables, and click on SessionTicket.

    Postman_ContextMenu.png#asset:379

  3. Copy your SessionTicket and paste into the corresponding environment variable. Postman also provides a convenient shortcut to this - just select the full text of the ticket (everything in the quote marks), right click, select “Set: [Environment]” for the environment you created to store your variables, and click on SessionTicket.

And that’s all you need to know to fully exercise the PlayFab suite of backend functions via Postman!

If you run into problems or questions, start by looking at our support resources.

Have fun!



Did you find this helpful?