Skip to main content
All CollectionsWorking with Cloud Code
Using Postman to test S2S and Client API calls
Using Postman to test S2S and Client API calls

brainCloud, S2S API, client API, MD5

Jason Liang avatar
Written by Jason Liang
Updated over a week ago

Postman is a good platform for testing and collaborating with your teammates whether you created S2S and client callable scripts or brainCloud off-the-shelf APIs.

To install Postman, simply:

S2S examples

Example of S2S Cloud Code script call (session-less)

  • Follow the Cloud Code Tutorial Link to create an S2S script and name it "AddNums".

  • Navigate to Design | Servers | My Servers page, click [+New Server], enter a name for your server (e.g. newGame_SERVER), and select Custom Server from the Server Type dropdown menu.

  • Leave the Base URL and IP Ranges blank, and hit Save, and the 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 can test them from Postman.

Note: "service": "script"; "operation": "RUN"

Example of brainCloud build-in S2S APIs call (session-less)

Note: "service": "itemCatalog"; "operation": "SYS_GET_CATALOG_ITEMS_PAGE" 

Example of brainCloud S2S API auth-call (session-based)

Note: "service": "authenticationV2"; "operation": "AUTHENTICATE"

  • Copy down the returned sessionId from the above auth-call.

  • Make a second request, using that sessionId and setting the packetId to 1, then hit Send and check the response.

Note: "service": "time"; "operation": "READ"

The S2S API calls documented in the API Ref 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.

Using Curl

When using the Curl command line with nested JSON parameters to test your S2S API call, recommend putting the parameters of the API call to a JSON file, then refer to this file with the --data option (-d) in the 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 is 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, the brainCloud API server will accept the request.

  • Open the imported request -- client-api-authenticateEmail (or create a request you own by following the steps below), and check the content of this request in the Body textbox. You will find that is the same format as the request which is called from the brainCloud portal API Explorer page.

Note: The following picture is the same API call which called from the brainCloud portal Design | Cloud Code | API Explorer page.

  • Copy the requested content from the Body textbox and append the App Secret to it (seeing the example below).

Note: Your App Secret can be found at brainCloud portal Design | Core App Info | Application IDs page.

  • Copy the whole piece of the request and paste it to an MD5 encrypt tool to generate an MD5 checksum.

Note: The following are some web links of MD5 encrypt tools

  • Click the Postman request Headers tab, add a key with the name "X-SIG", and 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.

Did this answer your question?