What Are the Best Practices When Testing the Airship Wallet API?

This article discusses some best practices around making test API calls against the Wallet API and what information is most useful to record in case assistance is needed. 

Making one-off API calls - Mac OS X:

You may at some point need to test an API call to check formatting or evaluate the appearance of text content or images. Depending on your operating system, there may be simple methods to make API calls from a command line, or you may need to investigate using something like a RESTful client tool.  

For Mac OS, Airship recommends using the Terminal application to send CURL commands.  A simple command can look like this:

Screen_Shot_2015-12-07_at_11.08.44_PM.png

 

Making one-off API calls - all operating systems:

For all operating systems, there are many free RESTful tools which have a significant feature set.  

  • Postman Chrome Extension
    Postman is a very powerful browser extension that integrates with Chrome.  It is available for any OS that supports Chrome and Chrome extensions, and allows for both import and export of configurations as well as saving parameters.

    A simple GET request to retrieve details about a template would look like this:
    Screen_Shot_2015-12-07_at_11.15.04_PM.png

 

Recording useful information:

If a question comes up and you need to reach out to Airship for assistance, we might ask for any of the following:

  • A ticketId for a successful API call where you are seeing unexpected results:
    {
       "ticketId":23147821
    * Connection #0 to host wallet-api.urbanairship.com left intact
    }%          
  • An error for a failed API call which might look like:
    
       "1":"Field: invalid json key in image Value title.string Error: Invalid Json Key",
       "2":"Field: invalid json key in image Value description.string Error: Invalid Json Key"
    }
    or: 
    {"code":400,"description":"Invalid Request Parameters.","details":"createPass API is not allowed for google templates"}% 

 

How to store the returned results from an API call:

Whether you are using CURL in the Terminal to make API calls or a RESTful client such as Postman, the returned results from an API Call can be an invaluable tool for investigating unexpected results or even just storing successful calls for future reference.

For example, you can store output of CURL commands by sending the output to a text file by ending the command with something like > PassDetails.json:

curl -X PUT https://wallet-api.urbanairship.com/v1/pass/123456\?api_key\=\<your_api_key\> -H "Api-Revision:1.2" -d 'json={"headers": {"logo_image": {"changeMessage": "changed the logo_image %25@", "value": "http://www.yourhost.com/some_image.png"}}}' > PassDetails.json 

 

Related Content:

Was this article helpful?
0 out of 0 found this helpful
Submit a request