1881 Partner Search API

1881 Partner Search API
The Partner Search API is a RESTFull service that utilizes the HTTP/GET verb. Parameters are passed
in the querystring of the HTTP request. The service can produce both xml and JSON formatted data.
The JSON approach is mainly intended for intranet integration, while the xml version is for machine
to machine integration.
Search:
Parameter name
userName
password
msisdn
query
format
Mandatory
Yes
Yes
Yes
No
No
level
No
catalogueIds
No
pageSize
page
No
No
geoCodes
No
xmlns
No
Description
The user name assigned to the customer by 1881.
The password assigned to the customer by 1881.
The a-number of the end-user performing the search.
The search query. Should be url encoded.
Set to “json” for JSON formatted data.
Remove this parameter or set to “xml” for XML formatted
data.
Defines the amount of data to return.
level=0;minimum amount of data
level=1;includes address information
level=2;additional company/person information (lower
performance)
Catalogueid=0; public person listings
Catalogueid=1; public company listings
Catalogueid=5; internal catalogue
If this is empty, all available catalogues is included
the list of id’s is separated by |.
Number of hits to return. Maximum value allowed is 300.
The page to return in the result set. If empty the first
page will be shown.
Geo code pairs separated with |.
Pair is presented in the following way:
Latitude:Longitude
Lat/long is encoded like 62.7836
Example:
62.7836:7.367456|62.7346: 5.4736
Invalid formatted geocodes will be ignored.
Namespace is by default included in xml format. To
exclude set xmlns=0.
Extended parameters for advanced search:
firstName
lastName
phone
street
postalCode
postalArea
region
No
No
No
No
No
No
No
FirstName. Should be url encoded.
LastName/CompanyName. Should be url encoded.
Phone, mobile, fax. Should be url encoded.
Street. Should be url encoded.
PostalCode. Should be url encoded.
PostalArea. Should be url encoded.
Region: Østlandet,Vestlandet,Nord-Norge,Midt-Norge,
municipality
No
Sørlandet. Should be url encoded.
Municipality. Should be url encoded.
Example:
/search?userName=<username>&msisdn=<msisdn>&password=<password>&query=<query>&le
vel=0&format=json
Example advanced search:
/search?userName=<username>&msisdn=<msisdn>&password=<password>&firstName=<firstna
me>&lastName=<lastname>&postalCode=<postalCode>&level=0&format=json
Details:
If you want to receive a specific resultitem and get more details you can use this one:
Parameter name
userName
password
msisdn
itemid
Mandatory
Yes
Yes
Yes
Yes
format
No
xmlns
No
Description
The user name assigned to the customer by 1881.
The password assigned to the customer by 1881.
The a-number of the end-user performing the search.
The result itemid. From resultlist: Results.ResultItem.
ItemId
Set to “json” for JSON formatted data.
Remove this parameter or set to “xml” for XML formatted
data.
Namespace is by default included in xml format. To
exclude set xmlns=0.
Example:
/search/Details?userName=<username>&msisdn=<msisdn>&password=<password>&itemid=<it
emid>&format=json
GetCatalogues:
If you want to receive the catalogues connected to the user you can use this one:
Parameter name
userName
password
msisdn
format
Mandatory
Yes
Yes
Yes
No
xmlns
No
Description
The user name assigned to the customer by 1881.
The password assigned to the customer by 1881.
The a-number of the end-user performing the search.
Set to “json” for JSON formatted data.
Remove this parameter or set to “xml” for XML formatted
data.
Namespace is by default included in xml format. To
exclude set xmlns=0.
Example:
/search/GetCatalogues?userName=<username>&msisdn=<msisdn>&password=<password>&for
mat=json
Search result
Field name
StatusMessage
TotalNumberOfResults
Results
Description
Contains an error message if the search fails, otherwise empty
The number of hits
The actual hits
.net proxy
1881 has developed a proxy for the service with strong typed message classes. The latest proxy can
be downloaded from http://api.1881bedrift.no/download/proxy.
const string ApiUrl = "http://test.1881bedrift.pragma.no/api/";
//GetResult - list
var qList = new SearchQuery
{
Msisdn = "########",
Password = "******",
UserName = "########",
QueryLevel = QueryLevels.Medium,
Query = "opplysningen",
PageSize = "5",
Page = "1",
IncludedCatalogues = new List<string>() {"0","1"}
};
using (var target = new SearchProxy())
{
var result = target.GetResult(new Uri(ApiUrl), qList);
//TODO: do something with the result
}
//GetResult - listitem
var qListItem = new SearchQuery
{
Msisdn = "########",
Password = "******",
UserName = "########",
ItemId = "200190583S1"
};
using (var target = new SearchProxy())
{
var result = target.GetResult(new Uri(ApiUrl), qListItem);
//TODO: do something with the result
}
//GetCatalogues
var qCatalogues = new SearchCataloguesRequest
{
Msisdn = "########",
Password = "******",
UserName = "########"
};
using (var target = new SearchProxy())
{
var result = target.GetSearchCatalogues(new Uri(ApiUrl), qCatalogues);
}
JQuery sample:
<script type="text/javascript" language="javascript">
var userName = "########";
var msisdn = "########";
var password = "*****";
$(document).ready(function () {
//need to user charset=ISO-8859-1 in order to get Norwegian characters correct to the search
service.
$("#QueryBox").autocomplete({
source: function (request, response) {
$.ajax({
contentType: "application/x-www-form-urlencoded;charset=ISO-8859-1",
url: GetSearchUrl(),
type: "GET",
dataType: "json",
success: function (data) {
response($.map(data.Results,
function (item) {
return { label: GetName(item) + "(" + GetPhone(item) + ")", value:
GetName(item), code: GetPhone(item) };
}))
}
, error: function (data)
{ $("#Phone")[0].innerText = "an error occurred while reading search service"; }
})
},
select: function (data) {
$("#Code").value = data.item;
$("#Phone").val(data.item);
},
minLength: 1
})
});
function GetName(item) {
if (item.CompanyName != null)
return item.CompanyName;
return item.FirstName + " " + item.LastName;
}
function GetSearchUrl() {
var data = "/search?userName="
+ userName
+ "&msisdn="
+ msisdn
+ "&password="
+ password
+ "&query="
+ $.URLEncode($("#QueryBox").val())
+ "&level=0&format=json";
$("#SearchUrl")[0].innerText = data;
return data;
}
function GetPhone(item) {
if (item.ContactPoints == null)
return "";
for (var i = 0; i < item.ContactPoints.length; i++) {
if (item.ContactPoints[i].ContactPointType == 2)
return item.ContactPoints[i].Address;
}
return "";
}
$("#QueryBox").bind("autocompleteselect", function (event, ui) {
$("#Code").val(ui.item.label);
$("#Phone")[0].innerText = ui.item.code;
});
$.extend({ URLEncode: function (c) {
var o = ''; var x = 0; c = c.toString(); var
while (x < c.length) {
var m = r.exec(c.substr(x));
if (m != null && m.length > 1 && m[1] !=
o += m[1]; x += m[1].length;
} else {
if (c[x] == ' ') o += '+'; else {
var d = c.charCodeAt(x); var h =
o += '%' + (h.length < 2 ? '0' :
} x++;
}
r = /(^[a-zA-Z0-9_.]*)/;
'') {
d.toString(16);
'') + h.toUpperCase();
} return o;
},
URLDecode: function (s) {
var o = s; var binVal, t; var r = /(%[^%]{2})/;
while ((m = r.exec(o)) != null && m.length > 1 && m[1] != '') {
b = parseInt(m[1].substr(1), 16);
t = String.fromCharCode(b); o = o.replace(m[1], t);
} return o;
}
});
</script>
Example result set:
<?xml version="1.0"?>
<SearchResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://1881.no/api/PartnerSearch">
<ExtensionData />
<Results>
<ResultItem>
<ExtensionData />
<Addresses />
<BirthDate xsi:nil="true" />
<Collection>B2B</Collection>
<ContactPoints>
<ContactPoint_Search>
<ExtensionData />
<Address>93257288</Address>
<ContactPointType>Landline</ContactPointType>
<IsMain>true</IsMain>
</ContactPoint_Search>
<ContactPoint_Search>
<ExtensionData />
<Address>[email protected]</Address>
<ContactPointType>Email</ContactPointType>
<IsMain>true</IsMain>
</ContactPoint_Search>
<ContactPoint_Search>
<ExtensionData />
<Address>98855641</Address>
<ContactPointType>Mobile</ContactPointType>
<IsMain>true</IsMain>
</ContactPoint_Search>
<ContactPoint_Search>
<ExtensionData />
<Address>www.pragma.no</Address>
<ContactPointType>HomePage</ContactPointType>
<IsMain>true</IsMain>
</ContactPoint_Search>
</ContactPoints>
<FirstName>Jonas</FirstName>
<Gender>Unknown</Gender>
<ItemId>b2b¤5¤103272¤110781</ItemId>
<LastName>Syrstad</LastName>
<ResultType>Person</ResultType>
</ResultItem>
</Results>
<TotalNumberOfResults>1</TotalNumberOfResults>
</SearchResponse>
ResultItem enum fields
Field name
Addresses.Address_Search .AddressType
ContactPoints.ContactPoint_Search. ContactPointType
Values
Visiting,
Postal,
Billing
HomePage,
ContactPoints.ContactPoint_Search.IsMain
Collection
Email,
Mobile,
Landline,
Fax
True,
False
Contacts ,
B2B
Contacts: collection from 1881.no Person /1881.no - Company
B2B: collection from catalogues defined
in B2B (employee/internal catalogues)
ResultType
Person,
Company