In order to use the REST API, you need to authenticate with our servers using HTTP Basic Authentication. Please consult relevant documentation for how to supply Basic Authentication on all REST requests.


Obtaining Credentials 

Credentials can be found on your dashboard, after clicking "Account Settings", and then "API Access".

  • Username: For a username, you need to obtain the current API access token for your organization.

  • Password: Use "x" or any other character as your password (this is ignored).

Note: You can reset your API token, however please make sure to update your authentication to the new access token.


Sample Code

We have provided a C# sample to give you a general idea of how this would work using the standard .NET HTTP stack (the WCF REST Starter Kit is definitely a simpler way of consuming RESTful services from .NET)

 using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.IO;
    namespace MobileFormsAPI
    {
        class Program
        {
            static string BASE_URL = "https://api.devicemagic.com/organizations/YOUR_ORGANIZATION_ID_GOES_HERE";
            static string USER_NAME = "YOUR_API_KEY_GOES_HERE";
            static string PASSWORD = "x";
            static void Main(string[] args)
            {
                HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(BASE_URL + "/devices.xml");
                string authInfo = USER_NAME + ":" + PASSWORD;
                authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
                req.Headers["Authorization"] = "Basic " + authInfo;
                HttpWebResponse response = (HttpWebResponse)req.GetResponse();
                Stream s = response.GetResponseStream();
                StreamReader reader = new StreamReader(s, Encoding.UTF8);
                string content = reader.ReadToEnd();
                Console.WriteLine(content);
                            Console.ReadLine();

Your output should look something like the following (depending on how many devices you have joined to your organization):


   
     
        2011-07-05T15:33:20Z
       
        3
        6537
        iPad_89E361BA-044A-55E5-A929-F2D52C4D310D
        10
        iPad Simulator
        2011-07-05T15:35:26Z
     
     
        2011-07-11T18:36:10Z
       
        3
        6738
        Android_000000000000000
        10
        Android Simulator
        2011-07-11T18:37:41Z
     
    

Be sure to authenticate in a similar way for other API requests.

Did this answer your question?