ACE Health Innovations

Key Concepts

The Getting Started Guide intended audience is developers tasked with understanding the functionality of the OpenFIT API. The end-users of OpenFIT are typically Clinicians or Clinical Supervisors who are tasked with gathering feedback in the form of Outcome Measurements/Surveys from Patients.

The OpenFIT Surveys and Analytics API can be integrated into almost any Case Management System, Electronic Health Record or eMental Health system. Many of the Entities below will already be familiar to you from your existing Clinical Record System.

Key OpenFIT Entities

Client

A Client represents a person using mental or behavioral health services supplied by your agency. Also can be called a Service user or Patient in your clinical records system.

Episode

An Episode represents a period of time during which a Client is receiving treatment. One or more Clients can be ssociated with a single Episode, for example in a Group therapy or Family therapy setting. Episode's can be called a Case or Dossier in your clinical records system.

Session

A Session represents usage of the service offerings of your agency and can be Face to face counselling, telephone support or online eMental health services. Sessions are often called Appointments in other clinical record systems.

Survey

An Episode represents a period of time during which a Clients is receiving treatment. One or more Clients can be ssociated with a single Episode, for example in a Group therapy or Family therapy setting. Episode's can be called a Case or Dossier in your clinical records system.


Connecting to OpenFIT via the API Management Portal

OpenFIT uses OAuth 2.0 Authentication to authenticate external calls to the OpenFIT API. During the Getting Started Guide you will use our Azure API Management Portal to generate Access Tokens using your username and password supplied by us. At this stage you should have signed up for a username/password. If you have any queries or issues using the OpenFIT API Management Portal please email support@acehealth.co


Creating your first ORS Survey

Each API Operation described below has a Try it button:


Try it

This leads to the API Operation data entry screen. From here you can execute GET and POST Methods relating to Clients, Episodes, Sessions and Surveys. You could use a client such as POSTMan or build code based on the code samples supplied for each API Operation. However we recommend using our Portal for this tutorial.



Step 1: Create a Client – POST api/ClientApi/Post

The Client HTTP POST method is described below along with a recap showing sample data posted via the OpenFIT Azure API Portal.

Client API

Post

Method for creating a new Client entity in the OpenFIT database.

Try it

Request URL

Request headers

(optional)
string
Media type of the body sent to the API.
string
OAuth 2.0 access token obtained from OpenFIT OAuth. Supported grant types: Resource owner password.

Request body

ExternalKey - The ExternalKey is the ID for the Client/Patient from the calling Clinical system. This is used by OpenFIT to help match data back to the calling system.

CompanyLocationID - Many healthcare agencies have multiple sites such as addiction outreach locations or subsiduary sites. Every company has at least one CompanyLocationID with ID of 1. More Company Locations can be created via a POST method on the Company Entity.

{
  "FirstName": "Alison",
  "LastName": "Doody",
  "DobYear": 1981,
  "DobMonth": 6,
  "Gender": "Female",
  "ExternalKey": "Ext-ClientID-01234",
  "CompanyLocationId": 1
}
<Client xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/openFit.Data.Model">
  <FirstName>Alison</FirstName>
  <LastName>Doody</LastName>
  <DobYear>1981</DobYear>
  <DobMonth>6</DobMonth>
  <Gender>Female</Gender>
  <ExternalKey>Ext-ClientID-01234</ExternalKey>
  <CompanyLocationId>1</CompanyLocationId>
</Client>

Code samples

@ECHO OFF
curl -v -X POST "/api/ClientAPI/Post"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
-H "Authorization: {access token}"
--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);
            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
            client.DefaultRequestHeaders.Add("Authorization", "{access token}");
            var uri = "/api/ClientAPI/Post?" + queryString;
            HttpResponseMessage response;
            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");
            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }
        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();
        try
        {
            URIBuilder builder = new URIBuilder("/api/ClientAPI/Post");
            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "application/json");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
            request.setHeader("Authorization", "{access token}");
            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);
            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();
            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}
<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "/api/ClientAPI/Post?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
                xhrObj.setRequestHeader("Authorization","{access token}");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"/api/ClientAPI/Post";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);
    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    [_request setValue:@"{access token}" forHTTPHeaderField:@"Authorization"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('/api/ClientAPI/Post');
$url = $request->getUrl();
$headers = array(
    // Request headers
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
    'Authorization' => '{access token}',
);
$request->setHeader($headers);
$parameters = array(
    // Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.urlencode({
})
try:
    conn = httplib.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/ClientAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.parse.urlencode({
})
try:
    conn = http.client.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/ClientAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('/api/ClientAPI/Post')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request headers
request['Authorization'] = '{access token}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end
puts response.body


Make sure to note the Client data you created as you will require it for Step 2: Creating an Episode.


Step 1 Recap

To recap here is a screenshot of entering Client details, Creating an OAuth Access Token, Posting Client Data to OpenFIT and view the Results through the OpenFIT Azure developer Portal.

Enter Client details, Create OAuth Access Token, Post Client Data to OpenFIT and view Results


Now move onto Step 2 by clicking on the Step 2 tab above.


Step 2: Create an Episode – POST api/EpisodeApi/Post

The Episode HTTP POST method is described below. Sample data can be posted in the same manner via the OpenFIT Azure API Portal outlined in Step 1.

Episode API

Post

Create a new Episode in the OpenFIT database.

Try it

Request URL

Request headers

(optional)
string
Media type of the body sent to the API.
string
OAuth 2.0 access token obtained from OpenFIT OAuth. Supported grant types: Resource owner password.

Request body

DiagnosisCode - An optional field that can be used to track the ICD10, DSM or other codes that you use in your Clinical software system.

ExternalKey - The ID number used to represent the Case/Episode/Dossier in the calling system. OpenFIT needs this to match the data sent back from OpenFIT to the correct Episode.

Status - The status of the Episode

  • 0 - Open (default)
  • 1 - Closed
  • 2 - Paused
  • 3 - Inactive

ClientIDs - A comma seperated list of the OpenFIT Client ID's. This is the list of Clients associated with an Episode. There should be at least one Client per Episode.

A useful method to obtain the OpenFIT Client ID is to use our Get Method with the Client ID from your Clinical record system:

UserIDs - A comma seperated list of the OpenFIT User ID's. This is the list of Clinicians associated with an Episode who are treating this Client/Patient. There should be at least one Clinician per Episode.

There are a number of methods to obtain the User IDs including:

{
  "DiagnosisCode": null,
  "StartDate": "2015-01-02",
  "ExternalKey": "ExternalEpisode-0020-123442342",
  "Status": 0,
  "ClientsIds": [
    6553
  ],
  "UsersIds": [
    100
  ]
}
<Episode xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/openFit.Data.Model">
    <DiagnosisCode>sample string 2</DiagnosisCode>
    <StartDate>2015-06-22</StartDate>
    <ExternalKey>ExtEpisodeID-0123-0002</ExternalKey>
    <Status>0</Status>
    <ClientsIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d2p1:int>6553</d2p1:int>
    </ClientsIds>
    <UsersIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d2p1:int>100</d2p1:int>
    </UsersIds>
</Episode>

Code samples

@ECHO OFF
curl -v -X POST /api/EpisodeApi/Post
- H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
-H "Authorization: {access token}"
--data-ascii "{body}"
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
    static class Program
            {
                static void Main()
                {
                    MakeRequest();
                    Console.WriteLine("Hit ENTER to exit...");
                    Console.ReadLine();
                }
                static async void MakeRequest()
                {
                    var client = new HttpClient();
                    var queryString = HttpUtility.ParseQueryString(string.Empty);
                    // Request headers
                    client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
                    client.DefaultRequestHeaders.Add("Authorization", "{access token}");
                    var uri = "/api/EpisodeApi/Post?" + queryString;
                    HttpResponseMessage response;
                    // Request body
                    byte[] byteData = Encoding.UTF8.GetBytes("{body}");
                    using (var content = new ByteArrayContent(byteData))
                    {
                        content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
                        response = await client.PostAsync(uri, content);
                    }
                }
            }
        }	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
        import org.apache.http.HttpEntity;
        import org.apache.http.HttpResponse;
        import org.apache.http.client.HttpClient;
        import org.apache.http.client.methods.HttpGet;
        import org.apache.http.client.utils.URIBuilder;
        import org.apache.http.impl.client.HttpClients;
        import org.apache.http.util.EntityUtils;
        public class JavaSample
        {
            public static void main(String[] args)
            {
                HttpClient httpclient = HttpClients.createDefault();
                try
                {
                    URIBuilder builder = new URIBuilder("/api/EpisodeApi/Post");
                    URI uri = builder.build();
                    HttpPost request = new HttpPost(uri);
                    request.setHeader("Content-Type", "application/json");
                    request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
                    request.setHeader("Authorization", "{access token}");
                    // Request body
                    StringEntity reqEntity = new StringEntity("{body}");
                    request.setEntity(reqEntity);
                    HttpResponse response = httpclient.execute(request);
                    HttpEntity entity = response.getEntity();
                    if (entity != null)
                    {
                        System.out.println(EntityUtils.toString(entity));
                    }
                }
                catch (Exception e)
                {
                    System.out.println(e.getMessage());
                }
            }
        }
<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
    url: "/api/EpisodeApi/Post?" + $.param(params),
            beforeSend: function(xhrObj){
            // Request headers
            xhrObj.setRequestHeader("Content-Type","application/json");
            xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            xhrObj.setRequestHeader("Authorization","{access token}");
        },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
        alert("success");
    })
        .fail(function() {
        alert("error");
    });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
    {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        NSString* path = @"/api/EpisodeApi/Post";
        NSArray* array = @[
                             // Request parameters
                         @"entities=true",
                          ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);
    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    [_request setValue:@"{access token}" forHTTPHeaderField:@"Authorization"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
    NSMutableDictionary* json = nil;
    NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        NSLog(@"%@", json);
    _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('/api/EpisodeApi/Post');
$url = $request->getUrl();
$headers = array(
    // Request headers
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
    'Authorization' => '{access token}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.urlencode({
})
try:
    conn = httplib.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/EpisodeAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
        'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.parse.urlencode({
})
try:
    conn = http.client.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/EpisodeAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('/api/EpisodeApi/Post')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request headers
request['Authorization'] = '{access token}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end
puts response.body


Step 3: Create a Session – POST api/SessionApi/Post

The Session HTTP POST method is described below. Sample data can be posted in the same manner via the OpenFIT Azure API Portal outlined in Step 1.

Session API

Post

Create a new Session in the OpenFIT database.

Try it

Request URL

Request headers

(optional)
string
Media type of the body sent to the API.
string
OAuth 2.0 access token obtained from OpenFIT OAuth. Supported grant types: Resource owner password.

Request body

EpisodeID - This is the OpenFIT Episode ID with which this Episode is associated with. Note that when creating test data multiple sessions do not generally occur on the same day so seperate session dates by at least a week.

An easy way to get the OpenFIT Episode ID is to call the operation Get?externalKey={externalKey} where ExternalKey is the Episode/Case/Dossier ID from your system.

ExternalKey (Optional) - You can supply the ID used for the Session or Appointment from your Clinical record system.

SessionTypeID - OpenFIT can record multiple Session types. The Session API Controller has a method GetSessionTypes

  • 1 - FaceToFace
  • 2 - Phone
  • 3 - Online
  • 4 - Unspecified

{
  "EpisodeId": 7145,
  "AppointmentDate": "2015-06-16T09:30:00",
  "ExternalKey": null,
  "SessionTypeId": 1
}
<Session xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/openFit.Data.Model">
    <EpisodeId>7145</EpisodeId>
    <AppointmentDate>2015-06-16T09:30:00</AppointmentDate>
    <SessionTypeId>1</SessionTypeId>
</Session>

Code samples

@ECHO OFF
curl -v -X POST "/api/SessionAPI/Post"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
-H "Authorization: {access token}"
--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);
            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
            client.DefaultRequestHeaders.Add("Authorization", "{access token}");
            var uri = "/api/SessionAPI/Post?" + queryString;
            HttpResponseMessage response;
            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");
            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }
        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();
        try
        {
            URIBuilder builder = new URIBuilder("/api/SessionAPI/Post");
            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "application/json");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
            request.setHeader("Authorization", "{access token}");
            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);
            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();
            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}
<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "/api/SessionAPI/Post?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
                xhrObj.setRequestHeader("Authorization","{access token}");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"/api/SessionAPI/Post";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);
    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    [_request setValue:@"{access token}" forHTTPHeaderField:@"Authorization"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('/api/SessionAPI/Post');
$url = $request->getUrl();
$headers = array(
    // Request headers
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
    'Authorization' => '{access token}',
);
$request->setHeader($headers);
$parameters = array(
    // Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.urlencode({
})
try:
    conn = httplib.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/SessionAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.parse.urlencode({
})
try:
    conn = http.client.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/SessionAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('/api/SessionAPI/Post')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request headers
request['Authorization'] = '{access token}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end
puts response.body


Step 4: Create ORS Survey – POST api/SurveyApi/Post

The Survey HTTP POST method is described below. Sample data can be posted in the same manner via the OpenFIT Azure API Portal outlined in Step 1.

Survey API

Post

Create a new Survey for a Client. A survey must be associated with a pre-existing Session for that Client.

Try it

Request URL

Request headers

(optional)
string
Media type of the body sent to the API.
string
OAuth 2.0 access token obtained from OpenFIT OAuth. Supported grant types: Resource owner password.

Request body

SessionId - The OpenFIT Session ID that this survey is linked to.

SurveyTemplateId - The ID of the Survey that is being completed by the Client. e.g. Adult ORS Survey. The list of Survey Templates can be obtained by calling /GetSurveyTemplates?languageCode={languageCode}. Available in over 20 languages (SA, BG, CN, DK, NL, GB, FI, FR, DE, GR, IL, IT, JP, NO, PL, RO, RU, SK, ES, SE, US).

ClientId - The OpenFIT ID of the Client that is completing the Survey.

Name - An optional field that can be used to record arbitrary name.

CollateralRaterId - This optional parameter is set with the OpenFIT ID of the Collatoral Rater. e.g. A Parent, Teacher or Social worker completing a survey on behalf of a Client.

{ 
"SessionId": 10462, 
"SurveyTemplateId": 1, 
"ClientID": 6553, 
"Name": "sample string 2",
"CollateralRaterId": 1
}
<Survey xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/openFit.Data.Model">
    <SessionId>10462</SessionId>
    <SurveyTemplateId>1</SurveyTemplateId>
    <ClientId>6553</ClientId>
    <Name>sample string 2</Name>
    <CollateralRaterId>1</CollateralRaterId>
</Survey>

Code samples

@ECHO OFF
curl -v -X POST "/api/SurveyAPI/Post"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
-H "Authorization: {access token}"
--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);
            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
            client.DefaultRequestHeaders.Add("Authorization", "{access token}");
            var uri = "/api/SurveyAPI/Post?" + queryString;
            HttpResponseMessage response;
            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");
            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }
        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();
        try
        {
            URIBuilder builder = new URIBuilder("/api/SurveyAPI/Post");
            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "application/json");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
            request.setHeader("Authorization", "{access token}");
            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);
            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();
            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}
<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "/api/SurveyAPI/Post?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
                xhrObj.setRequestHeader("Authorization","{access token}");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"/api/SurveyAPI/Post";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);
    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    [_request setValue:@"{access token}" forHTTPHeaderField:@"Authorization"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('/api/SurveyAPI/Post');
$url = $request->getUrl();
$headers = array(
    // Request headers
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
    'Authorization' => '{access token}',
);
$request->setHeader($headers);
$parameters = array(
    // Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.urlencode({
})
try:
    conn = httplib.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/SurveyAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.parse.urlencode({
})
try:
    conn = http.client.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/SurveyAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('/api/SurveyAPI/Post')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request headers
request['Authorization'] = '{access token}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end
puts response.body


Step 5: Create ORS Survey Answers – POST api/AnswerApi/Post

The Answer HTTP POST method is described below. Sample data can be posted in the same manner via the OpenFIT Azure API Portal outlined in Step 1.

Answer API

Post

Method called for creating answers to Survey questions. The Answer API needs to be called for each question in a survey. For example the Adult ORS survey has 4 questions. Therefore the Answer POST method needs to be called 4 times.

Try it

Request URL

Request headers

(optional)
string
Media type of the body sent to the API.
string
OAuth 2.0 access token obtained from OpenFIT OAuth. Supported grant types: Resource owner password.

Request body

Value - The question response. For example in the Adult ORS each Question has a numerical value between 0 – 10.

SurveyID - The survey ID is gotten from the response to the api/SurveyApi/Post Method.

QuestionID - The question ID. GET api/SurveyApi/GetQuestions?surveyTemplateId={surveyTemplateId}&languageCode={languageCode} will return the QuestionIDs for a particular survey in a particular language (e.g. US for English)

The Answer API Post method should be called for each survey question to be answered. For example 4 times to answer each of the 4 Adult ORS questions.

A screenshot of the Adult ORS Survey used in this example

{ 
"Value": 2.0, 
"SurveyId": 3, 
"QuestionId": 4
 }
<Answer xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/openFit.Data.Model"> 
<QuestionId>4</QuestionId> 
<SurveyId>3</SurveyId> 
<Value>2</Value> 
</Answer>

Code samples

@ECHO OFF
curl -v -X POST "/api/AnswerAPI/Post"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
-H "Authorization: {access token}"
--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);
            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
            client.DefaultRequestHeaders.Add("Authorization", "{access token}");
            var uri = "/api/AnswerAPI/Post?" + queryString;
            HttpResponseMessage response;
            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");
            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }
        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();
        try
        {
            URIBuilder builder = new URIBuilder("/api/AnswerAPI/Post");
            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "application/json");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
            request.setHeader("Authorization", "{access token}");
            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);
            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();
            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}
<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "/api/AnswerAPI/Post?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
                xhrObj.setRequestHeader("Authorization","{access token}");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"/api/AnswerAPI/Post";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);
    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    [_request setValue:@"{access token}" forHTTPHeaderField:@"Authorization"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('/api/AnswerAPI/Post');
$url = $request->getUrl();
$headers = array(
    // Request headers
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
    'Authorization' => '{access token}',
);
$request->setHeader($headers);
$parameters = array(
    // Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.urlencode({
})
try:
    conn = httplib.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/AnswerAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
    'Authorization': '{access token}',
}
params = urllib.parse.urlencode({
})
try:
    conn = http.client.HTTPSConnection('openfitapi.azure-api.net')
    conn.request("POST", "/AnswerAPI/Post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('/api/AnswerAPI/Post')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request headers
request['Authorization'] = '{access token}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end
puts response.body


Step 6: Review the data in OpenFIT UI

Simply use the OpenFIT login credentials you were supplied with and used to generate OAuth tokens during Steps 1-5.

Any questions drop us a line to developer@acehealth.co