Postman is a good platform for testing and collaborating with your teammates either you created S2S and client callable scripts or brainCloud off-the-shelf APIs.
To install Postman, simply:
Download from https://www.getpostman.com/
Choose your platform, and complete the installation process
Import a Collection
After installing Postman, you can import Postman Collections you have or create a new collection. The importing collection can be a JSON file or a shared link from your teammates.
The following is a shared Postman collection link that includes several requests for running user-created cloud code scripts and brainCloud build-in API calls examples, you can import it from Import From Link tab.
Example of S2S Cloud Code script call (session-less)
Follow CC Tutorial Link below to create an S2S script named it as "AddNums". https://getbraincloud.com/apidocs/cloud-code-central/cloud-code-tutorials/cloud-code-tutorial1-your-first-script/
Navigate to Design | Cloud Code | My Servers page, click [+New Server], enter a name for your server (e.g. newGame_SERVER), select Custom Server from Server Type dropdown menu.
Leave the Base URL and IP Ranges blank, hit Save, portal page will generate a Server Secret for you.
Now you have created an S2S script and configured the S2S server in the brainCloud dashboard, you are able to test them from Postman.
Open the imported request -- script-AddNums, or create a request you own by following the pattern of the picture below (Method: POST, URL: https://sharedprod.braincloudservers.com/s2sdispatcher), then hit Send and check the response.
Note: "service" : "script"; "operation" : "RUN"
Example of brainCloud build-in S2S APIs call (session-less)
Open the imported request -- itemCatalog-SYS_GET_CATALOG_ITEMS_PAGE, or create a request your own by following the pattern of the picture below (Method: POST, URL: https://sharedprod.braincloudservers.com/s2sdispatcher), then hit Send and check the response.
Note: "service" : "itemCatalog"; "operation" : "SYS_GET_CATALOG_ITEMS_PAGE"
Example of brainCloud S2S API auth-call (session-based)
Open the imported request -- prod-session-based-auth, or create a request your own by following the pattern of the picture below (Method: POST, URL: https://sharedprod.braincloudservers.com/s2sdispatcher), then hit Send and check the response.
Note: "service" : "authenticationV2"; "operation" : "AUTHENTICATE"
Copy down the returned
sessionIdfrom the above auth-call.
Make a second request, using that
sessionIdand setting the
packetIdto 1, then hit Send and check the response.
Note: "service" : "time"; "operation" : "READ"
The API calls documented in the API Ref (http://getbraincloud.com/apidocs/apiref/?raw#s2s) are mapped to discrete Services and Operations on the server.
The codes, together with operation-specific parameters (specified in the JSON data object) are used to send commands to the server.
Note: Only the API Calls in the S2S section of the API Ref can be used for S2S calls.
When using Curl command line with nested JSON parameters to test your S2S API call, recommend putting parameters of the API call to a JSON file, then refer to this file with --data option (-d) in curl command.
curl -d "@paraItemCat.json" -X POST https://sharedprod.braincloudservers.com/s2sdispatcher -H "Content-Type: applicaiton/json"
Example of the client API call
Every request that sent to the brainCloud client API server has an MD5 check attached to it in the request header.
The MD5 value is calculated by taking the body being sent to the API, appending the app secret to it, and then calculating the MD5 on all of that.
Only if the MD5 value is present, and checks out, brainCloud API server will accept the request.
Note: Method: POST, URL: https://sharedprod.braincloudservers.com/dispatcherv2
Open the imported request -- client-api-authenticateEmail (or create a request you own by following the steps below), check the content of this request in the Body textbox. You will find that is exactly the same format as the request which called from the brainCloud portal API Explorer page.
Note: The following picture is the same API call which called from brainCloud portal Design | Cloud Code | API Explorer page.
Copy the request content from the Body textbox and append the App Secret to it (seeing the example below).
Note: You App Secret can be found at brainCloud portal Design | Core App Info | Application IDs page.
Copy the whole piece of the request and paste to a MD5 encrypt tool to generate a MD5 checksum.
Note: The following are some web links of MD5 encrypt tools
Click Postman request Headers tab, add a key with name "X-SIG", paste the MD5 checksum as the value.
Now you are good to go! Click the Send button and check the response from the brainCloud API server.
Go to brainCloud portal Monitoring | User Monitoring | User Summary to check the user you just created from Postman.