Search…
Handling responses

Making Requests

All API calls require the Medable-Client-Key header. An Organization creates one or more applications, providing the public key to all its clients. Note that some web applications may employ the Medable-Csrf-Token. If an application is configured as such, each authenticated request must include HTTP response header of the same name, sent with the login response (and each subsequent authenticated response).
For semantic reasons, API access to Objects is always through the use of the object plural name (e.g. /accounts).

Example: GET/accounts/me

JavaScript
Objective-C
1
$.ajax({
2
url: "https://api.dev.medable.com/example/accounts/me",
3
type: "GET",
4
contentType: "application/json; charset=UTF-8",
5
dataType : "json",
6
headers: {
7
"Medable-Client-Key": "GsAqlhnIMzrDeD8V2MBQWq",
8
"Medable-Csrf-Token": "MvFkpcS0BCM9qpf4K0pFMyiE57e3VtI5Cb38NfQn6eWiPPp6CqZCOOrAljDZYWnU"
9
}
10
});
Copied!
1
[[MDAPIClient sharedClient]
2
currentAccount:^(MDAccount* account, MDFault* fault)
3
{
4
if (fault)
5
{
6
// Fault handling
7
}
8
else
9
{
10
11
}
12
}];
Copied!

Handling Responses

API responses always consist of JSON documents with an object property, whose values will either list or the name of the object type, such as account or connection.

Example: Single Object Response

GET/account

1
{
2
"_id": "5516ee2634d8d93428169c0e",
3
"object": "account",
4
"roles": [
5
"000000000000000000000007"
6
],
7
...
8
}
Copied!
When the response is an array, the data property contains the resulting array, and the hasMore property contains a boolean value that is true if there are more results that can be retrieved using Paging.

Example: Multiple Object Response

GET /c_examples?limit=1

1
{
2
"data": [
3
{
4
"_id": "5519c01aae2fd2b02915c81f",
5
"object": "c_example",
6
"creator": {
7
"_id": "5516ee2634d8d93428169c0e",
8
"object": "Account",
9
"path": "/accounts/5516ee2634d8d93428169c0e"
10
},
11
...
12
}
13
],
14
"hasMore": true,
15
"object": "list"
16
}
Copied!
Lists are typically sorted by _id, in descending order. As such, results will have the newest items at the front of the result set.
If the response is a fault, the object property will be fault (see Faults).

GET /accounts/5516ee2634d8d93428169c0e/profile/missing

1
{
2
"object": "fault",
3
"name": "error",
4
"code": "kNotFound",
5
"status": 404,
6
"reason": "Property not found.",
7
"message":"Resource not found.",
8
"path":"profile.missing"
9
}
Copied!
Some responses, such as those retrieved via direct Property Access, will have result as their object property, as they do not represent a concrete, registered object type. Note, however, that directly accessed array properties will always be list objects.

Result Example

1
GET /accounts/5516ee2634d8d93428169c0e/name
2
3
{
4
"object": "result",
5
"data": {
6
"first": "John",
7
"last": "Smith"
8
}
9
}
Copied!

List Example

1
{
2
"object": "list",
3
"data": [
4
"000000000000000000000007"
5
],
6
"hasMore": false
7
}
Copied!
Last modified 1mo ago