Logo
Submit a request
Follow

API Example Code

The following example code shows how to retrieve a list of service requests using the BlueFolder API. In each example below, replace the text API_TOKEN with a valid API Token from your BlueFolder account.

cURL

curl -X POST --user API_TOKEN:x https://app.bluefolder.com/api/2.0/serviceRequests/list.aspx
  --data "<request><listType>full</listType></request>"

C#

    var username = "API_TOKEN";
    var password = "x";
    var encoded = 
           Convert.ToBase64String(
               System.Text.Encoding.GetEncoding("ISO-8859-1")
                   .GetBytes(username + ":" + password)
           );
    var request = 
        (System.Net.HttpWebRequest)
        System.Net.WebRequest.Create(
            "https://app.bluefolder.com/api/2.0/serviceRequests/list.aspx");
    
    request.Headers.Add("Authorization", "Basic " + encoded);
    request.PreAuthenticate = true;

    request.ContentType = "text/xml";
    request.Method = "POST";

    using (var sw = new System.IO.StreamWriter(request.GetRequestStream()))
    {
       sw.Write("<request><listType>full</listType></request>");
    }

    var content = "";
    using (var response = (System.Net.HttpWebResponse)request.GetResponse())
    {
        using (var responseStream = response.GetResponseStream())
        {
            if (responseStream.CanRead)
            {
                using (var reader = new System.IO.StreamReader(responseStream))
                {
                    var content = reader.ReadToEnd();

                    // Do something with the content that is returned here

                    reader.Close();

                    return content;
                }
            }
        }
    }

PHP

<?php

$request_xml="<request><listType>basic</listType></request>";

//Initialize handle and set options
$username='API_TOKEN';
$password='x';

$ch=curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'https://app.bluefolder.com/api/2.0/serviceRequests/list.aspx'); 
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_xml); 
 
$result=curl_exec($ch); 

//Do something with the $result here

?>
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request