{"id":5228,"date":"2022-11-14T02:30:37","date_gmt":"2022-11-14T02:30:37","guid":{"rendered":"https:\/\/serviceobjects.wpaladdin.com\/?page_id=5228"},"modified":"2025-09-26T13:23:40","modified_gmt":"2025-09-26T20:23:40","slug":"pe2-rest","status":"publish","type":"page","link":"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/","title":{"rendered":"PE2 &#8211; REST"},"content":{"rendered":"\n<div class=\"wp-block-create-block-tabs\"><ul class=\"tab-labels\" role=\"tablist\" aria-label=\"tabbed content\"><li class=\"tab-label active\" role=\"tab\" aria-selected=\"true\" aria-controls=\"C#\" tabindex=\"0\">C#<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"Python\" tabindex=\"0\">Python<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"NodeJS\" tabindex=\"0\">NodeJS<\/li><\/ul><div class=\"tab-content\">\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Phone Exchange C# Rest Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\ufeff\nusing System.Web;\n\nnamespace phone_exchange_2_dot_net.REST\n{\n    \/\/\/ &lt;summary>\n    \/\/\/ Provides functionality to call the ServiceObjects Phone Exchange (PE2) REST API's GetExchangeInfo endpoint,\n    \/\/\/ retrieving phone exchange information (e.g., carrier, line type, ported status) for a given phone number\n    \/\/\/ with fallback to a backup endpoint for reliability in live mode.\n    \/\/\/ &lt;\/summary>\n    public static class GetExchangeInfoClient\n    {\n        \/\/ Base URL constants: production, backup, and trial\n        private const string LiveBaseUrl = \"https:\/\/sws.serviceobjects.com\/pe2\/web.svc\/json\/\";\n        private const string BackupBaseUrl = \"https:\/\/swsbackup.serviceobjects.com\/pe2\/web.svc\/json\/\";\n        private const string TrialBaseUrl = \"https:\/\/trial.serviceobjects.com\/pe2\/web.svc\/json\/\";\n\n        \/\/\/ &lt;summary>\n        \/\/\/ Synchronously calls the GetExchangeInfo REST endpoint to retrieve phone exchange information,\n        \/\/\/ attempting the primary endpoint first and falling back to the backup if the response is invalid\n        \/\/\/ (Error.TypeCode == \"3\") in live mode.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"input\">The input parameters including phone number, country code, and license key.&lt;\/param>\n        \/\/\/ &lt;returns>Deserialized &lt;see cref=\"PE2Response\"\/> containing phone exchange data or an error.&lt;\/returns>\n        public static PE2Response Invoke(GetExchangeInfoInput input)\n        {\n            \/\/ Use query string parameters so missing\/optional fields don't break the URL\n            string url = BuildUrl(input, input.IsLive ? LiveBaseUrl : TrialBaseUrl);\n            PE2Response response = Helper.HttpGet&lt;PE2Response>(url, input.TimeoutSeconds);\n\n            \/\/ Fallback on error in live mode\n            if (input.IsLive &amp;&amp; !IsValid(response))\n            {\n                string fallbackUrl = BuildUrl(input, BackupBaseUrl);\n                PE2Response fallbackResponse = Helper.HttpGet&lt;PE2Response>(fallbackUrl, input.TimeoutSeconds);\n                return fallbackResponse;\n            }\n\n            return response;\n        }\n\n        \/\/\/ &lt;summary>\n        \/\/\/ Asynchronously calls the GetExchangeInfo REST endpoint to retrieve phone exchange information,\n        \/\/\/ attempting the primary endpoint first and falling back to the backup if the response is invalid\n        \/\/\/ (Error.TypeCode == \"3\") in live mode.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"input\">The input parameters including phone number, country code, and license key.&lt;\/param>\n        \/\/\/ &lt;returns>Deserialized &lt;see cref=\"PE2Response\"\/> containing phone exchange data or an error.&lt;\/returns>\n        public static async Task&lt;PE2Response> InvokeAsync(GetExchangeInfoInput input)\n        {\n            \/\/ Use query string parameters so missing\/optional fields don't break the URL\n            string url = BuildUrl(input, input.IsLive ? LiveBaseUrl : TrialBaseUrl);\n            PE2Response response = await Helper.HttpGetAsync&lt;PE2Response>(url, input.TimeoutSeconds).ConfigureAwait(false);\n\n            \/\/ Fallback on error in live mode\n            if (input.IsLive &amp;&amp; !IsValid(response))\n            {\n                string fallbackUrl = BuildUrl(input, BackupBaseUrl);\n                PE2Response fallbackResponse = await Helper.HttpGetAsync&lt;PE2Response>(fallbackUrl, input.TimeoutSeconds).ConfigureAwait(false);\n                return fallbackResponse;\n            }\n\n            return response;\n        }\n\n        \/\/ Build the full request URL, including URL-encoded query string\n        public static string BuildUrl(GetExchangeInfoInput input, string baseUrl)\n        {\n            \/\/ Construct query string with URL-encoded parameters\n            string qs = $\"GetExchangeInfo?\" +\n                        $\"PhoneNumber={Helper.UrlEncode(input.PhoneNumber)}\" +\n                        $\"&amp;LicenseKey={Helper.UrlEncode(input.LicenseKey)}\";\n            return baseUrl + qs;\n        }\n\n        private static bool IsValid(PE2Response response) => response?.Error == null || response.Error.TypeCode != \"3\";\n\n        \/\/\/ &lt;summary>\n        \/\/\/ Input parameters for the GetExchangeInfo API call. Represents a phone number to retrieve exchange information.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"PhoneNumber\">The phone number to validate (e.g., \"1234567890\").&lt;\/param>\n        \/\/\/ &lt;param name=\"CountryCode\">1-3 digit country calling code (e.g., \"1\"). Optional.&lt;\/param>\n        \/\/\/ &lt;param name=\"Country\">ISO2, ISO3, or country name (e.g., \"US\"). Optional.&lt;\/param>\n        \/\/\/ &lt;param name=\"IPAddress\">IPv4 address. Optional.&lt;\/param>\n        \/\/\/ &lt;param name=\"CallerCountry\">ISO2 or ISO3 code representing the caller's country. Optional.&lt;\/param>\n        \/\/\/ &lt;param name=\"Extras\">Comma-separated list of possible options. Optional.&lt;\/param>\n        \/\/\/ &lt;param name=\"LicenseKey\">The license key to authenticate the API request.&lt;\/param>\n        \/\/\/ &lt;param name=\"IsLive\">Indicates whether to use the live service (true) or trial service (false).&lt;\/param>\n        \/\/\/ &lt;param name=\"TimeoutSeconds\">Timeout duration for the API call, in seconds.&lt;\/param>\n        public record GetExchangeInfoInput(\n            string PhoneNumber = \"\",\n            string CountryCode = \"\",\n            string Country = \"\",\n            string IPAddress = \"\",\n            string CallerCountry = \"\",\n            string Extras = \"\",\n            string LicenseKey = \"\",\n            string Token = \"\",\n            bool IsLive = true,\n            int TimeoutSeconds = 15\n        );\n    }\n}\n\n\n\ufeffusing System.Runtime.Serialization;\nusing System.Linq;\n\nnamespace phone_exchange_2_dot_net.REST\n{\n    \/\/\/ &lt;summary>\n    \/\/\/ Response from PE2 GetExchangeInfo and GetInternationalExchangeInfo APIs, containing phone exchange information.\n    \/\/\/ &lt;\/summary>\n    [DataContract]\n    public class PE2Response\n    {\n        public ExchangeInfo[] ExchangeInfoResults { get; set; }\n        public InternationalExchangeInfo InternationalExchangeInfo { get; set; }\n        public Error Error { get; set; }\n\n        public override string ToString()\n        {\n            string exchangeInfoStr = ExchangeInfoResults != null\n                ? string.Join(\"\\n\", ExchangeInfoResults.Select(r => r.ToString()))\n                : \"null\";\n            string internationalInfoStr = InternationalExchangeInfo != null\n                ? InternationalExchangeInfo.ToString()\n                : \"\";\n            return $\"PE2Response:\\n\" +\n                   $\"ExchangeInfoResults:\\n{exchangeInfoStr}\\n\" +\n                   $\"InternationalExchangeInfo:\\n{internationalInfoStr}\\n\" +\n                   $\"Error: {(Error != null ? Error.ToString() : \"null\")}\";\n        }\n    }\n\n    \/\/\/ &lt;summary>\n    \/\/\/ Phone exchange information for a validated phone number (USA\/Canada).\n    \/\/\/ &lt;\/summary>\n    [DataContract]\n    public class ExchangeInfo\n    {\n        public string PhoneNumber { get; set; }\n        public string Name { get; set; }\n        public string City { get; set; }\n        public string State { get; set; }\n        public string Country { get; set; }\n        public string LineType { get; set; }\n        public string TimeZone { get; set; }\n        public string Latitude { get; set; }\n        public string Longitude { get; set; }\n        public string SMSAddress { get; set; }\n        public string MMSAddress { get; set; }\n        public PortedInfo PortedInfo { get; set; }\n        public string NoteCodes { get; set; }\n        public string NoteDescriptions { get; set; }\n\n        public override string ToString()\n        {\n            string portedInfoStr = PortedInfo != null\n                ? PortedInfo.ToString()\n                : \"\";\n            return $\"ExchangeInfo:\\n\" +\n                   $\"PhoneNumber: {PhoneNumber}\\n\" +\n                   $\"Name: {Name}\\n\" +\n                   $\"City: {City}\\n\" +\n                   $\"State: {State}\\n\" +\n                   $\"Country: {Country}\\n\" +\n                   $\"LineType: {LineType}\\n\" +\n                   $\"TimeZone: {TimeZone}\\n\" +\n                   $\"Latitude: {Latitude}\\n\" +\n                   $\"Longitude: {Longitude}\\n\" +\n                   $\"SMSAddress: {SMSAddress}\\n\" +\n                   $\"MMSAddress: {MMSAddress}\\n\" +\n                   $\"PortedInfo: {portedInfoStr}\\n\" +\n                   $\"NoteCodes: {NoteCodes}\\n\" +\n                   $\"NoteDescriptions: {NoteDescriptions}\";\n        }\n    }\n\n    \/\/\/ &lt;summary>\n    \/\/\/ Ported information for a phone number.\n    \/\/\/ &lt;\/summary>\n    [DataContract]\n    public class PortedInfo\n    {\n        public string OriginalName { get; set; }\n        public string OriginalLineType { get; set; }\n        public string PortedDate { get; set; }\n        public string LATA { get; set; }\n\n        public override string ToString()\n        {\n            return $\"OriginalName: {OriginalName}, OriginalLineType: {OriginalLineType}, PortedDate: {PortedDate}, LATA: {LATA}\";\n        }\n    }\n\n    \/\/\/ &lt;summary>\n    \/\/\/ International phone exchange information for a validated phone number.\n    \/\/\/ &lt;\/summary>\n    [DataContract]\n    public class InternationalExchangeInfo\n    {\n        public string PhoneNumberIn { get; set; }\n        public string CountryCode { get; set; }\n        public string FormatNational { get; set; }\n        public string Extension { get; set; }\n        public string Locality { get; set; }\n        public string LocalityMatchLevel { get; set; }\n        public string TimeZone { get; set; }\n        public string Latitude { get; set; }\n        public string Longitude { get; set; }\n        public string Country { get; set; }\n        public string CountryISO2 { get; set; }\n        public string CountryISO3 { get; set; }\n        public string FormatInternational { get; set; }\n        public string FormatE164 { get; set; }\n        public string Carrier { get; set; }\n        public string LineType { get; set; }\n        public string SMSAddress { get; set; }\n        public string MMSAddress { get; set; }\n        public bool IsValid { get; set; }\n        public bool IsValidForRegion { get; set; }\n        public string NoteCodes { get; set; }\n        public string NoteDescriptions { get; set; }\n\n        public override string ToString()\n        {\n            return $\"InternationalExchangeInfo:\\n\" +\n                   $\"PhoneNumberIn: {PhoneNumberIn}\\n\" +\n                   $\"CountryCode: {CountryCode}\\n\" +\n                   $\"FormatNational: {FormatNational}\\n\" +\n                   $\"Extension: {Extension}\\n\" +\n                   $\"Locality: {Locality}\\n\" +\n                   $\"LocalityMatchLevel: {LocalityMatchLevel}\\n\" +\n                   $\"TimeZone: {TimeZone}\\n\" +\n                   $\"Latitude: {Latitude}\\n\" +\n                   $\"Longitude: {Longitude}\\n\" +\n                   $\"Country: {Country}\\n\" +\n                   $\"CountryISO2: {CountryISO2}\\n\" +\n                   $\"CountryISO3: {CountryISO3}\\n\" +\n                   $\"FormatInternational: {FormatInternational}\\n\" +\n                   $\"FormatE164: {FormatE164}\\n\" +\n                   $\"Carrier: {Carrier}\\n\" +\n                   $\"LineType: {LineType}\\n\" +\n                   $\"SMSAddress: {SMSAddress}\\n\" +\n                   $\"MMSAddress: {MMSAddress}\\n\" +\n                   $\"IsValid: {IsValid}\\n\" +\n                   $\"IsValidForRegion: {IsValidForRegion}\\n\" +\n                   $\"NoteCodes: {NoteCodes}\\n\" +\n                   $\"NoteDescriptions: {NoteDescriptions}\";\n        }\n    }\n\n    \/\/\/ &lt;summary>\n    \/\/\/ Error object for PE2 API responses.\n    \/\/\/ &lt;\/summary>\n    [DataContract]\n    public class Error\n    {\n        public string Type { get; set; }\n        public string Desc { get; set; }\n        public string TypeCode { get; set; }\n        public string DescCode { get; set; }\n\n        public override string ToString()\n        {\n            return $\"Desc: {Desc}, TypeCode: {TypeCode}, DescCode: {DescCode}, Type: {Type}\";\n        }\n    }\n}\n\n\n\ufeffusing System.Net.Http;\nusing System.Text.Json;\nusing System.Text.Json.Serialization;\nusing System.Web;\n\nnamespace phone_exchange_2_dot_net.REST\n{\n    public static class Helper\n    {\n        public static async Task&lt;T> HttpGetAsync&lt;T>(string url, int timeoutSeconds)\n        {\n            HttpClient HttpClient = new HttpClient();\n            HttpClient.Timeout = TimeSpan.FromSeconds(timeoutSeconds);\n            using var httpResponse = await HttpClient.GetAsync(url).ConfigureAwait(false);\n            httpResponse.EnsureSuccessStatusCode();\n            var stream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);\n            return JsonSerializer.Deserialize&lt;T>(stream)!;\n        }\n\n        public static T HttpGet&lt;T>(string url, int timeoutSeconds)\n        {\n            using var httpClient = new HttpClient \n            { \n                Timeout = TimeSpan.FromSeconds(timeoutSeconds) \n            };\n\n            using var request = new HttpRequestMessage(HttpMethod.Get, url);\n            using HttpResponseMessage response = httpClient\n                .SendAsync(request)\n                .GetAwaiter()\n                .GetResult();\n            response.EnsureSuccessStatusCode();\n            using Stream responseStream = response.Content\n                .ReadAsStreamAsync()\n                .GetAwaiter()\n                .GetResult();\n            var options = new JsonSerializerOptions\n            {\n                PropertyNameCaseInsensitive = true\n            };\n            object? obj = JsonSerializer.Deserialize(responseStream, typeof(T), options);\n            T result = (T)obj!;\n            return result;\n        }\n\n        public static string UrlEncode(string value) => HttpUtility.UrlEncode(value ?? string.Empty);\n    }\n}<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Phone Exchange Python Rest Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from pe2_response import PE2Response, ExchangeInfo, InternationalExchangeInfo, PortedInfo, Error\nimport requests\n\n# Endpoint URLs for ServiceObjects Phone Exchange (PE2) API\nprimary_url = \"https:\/\/sws.serviceobjects.com\/pe2\/web.svc\/json\/GetExchangeInfo?\"\nbackup_url = \"https:\/\/swsbackup.serviceobjects.com\/pe2\/web.svc\/json\/GetExchangeInfo?\"\ntrial_url = \"https:\/\/trial.serviceobjects.com\/pe2\/web.svc\/json\/GetExchangeInfo?\"\n\ndef get_exchange_info(\n    phone_number: str,\n    license_key: str = None,\n    is_live: bool = True\n) -> PE2Response:\n    \"\"\"\n    Call ServiceObjects Phone Exchange (PE2) API's GetExchangeInfo endpoint\n    to retrieve phone exchange information for a given US\/Canada phone number.\n\n    Parameters:\n        phone_number: The phone number to validate (e.g., \"8051234567\").\n        license_key: Your ServiceObjects license key.\n        is_live: Use live or trial servers.\n\n    Returns:\n        PE2Response: Parsed JSON response with phone exchange results or error details.\n\n    Raises:\n        RuntimeError: If the API returns an error payload.\n        requests.RequestException: On network\/HTTP failures (trial mode).\n    \"\"\"\n    params = {\n        \"PhoneNumber\": phone_number,\n        \"LicenseKey\": license_key,\n    }\n    # Select the base URL: production vs trial\n    url = primary_url if is_live else trial_url\n\n    try:\n        # Attempt primary (or trial) endpoint\n        response = requests.get(url, params=params, timeout=10)\n        response.raise_for_status()\n        data = response.json()\n\n        # If API returned an error in JSON payload, trigger fallback\n        error = data.get('Error')\n        if not (error is None or error.get('TypeCode') != \"3\"):\n            if is_live:\n                # Try backup URL\n                response = requests.get(backup_url, params=params, timeout=10)\n                response.raise_for_status()\n                data = response.json()\n\n                # If still error, propagate exception\n                if 'Error' in data:\n                    raise RuntimeError(f\"Phone Exchange service error: {data['Error']}\")\n            else:\n                # Trial mode error is terminal\n                raise RuntimeError(f\"Phone Exchange trial error: {data['Error']}\")\n\n        # Convert JSON response to PE2Response for structured access\n        error = Error(**data.get(\"Error\", {})) if data.get(\"Error\") else None\n        exchange_info_results = []\n        if \"ExchangeInfoResults\" in data:\n            for ei in data.get(\"ExchangeInfoResults\", []):\n                if isinstance(ei, dict):\n                    ported_info_list = []\n                    if \"PortedInfo\" in ei and ei.get(\"PortedInfo\"):\n                        for pi in ei.get(\"PortedInfo\", []):\n                            if isinstance(pi, dict):\n                                ported_info_list.append(PortedInfo(\n                                    OriginalName=pi.get(\"OriginalName\"),\n                                    OriginalLineType=pi.get(\"OriginalLineType\"),\n                                    PortedDate=pi.get(\"PortedDate\"),\n                                    LATA=pi.get(\"LATA\")\n                                ))\n                    exchange_info_results.append(ExchangeInfo(\n                        PhoneNumber=ei.get(\"PhoneNumber\"),\n                        Name=ei.get(\"Name\"),\n                        City=ei.get(\"City\"),\n                        State=ei.get(\"State\"),\n                        Country=ei.get(\"Country\"),\n                        LineType=ei.get(\"LineType\"),\n                        TimeZone=ei.get(\"TimeZone\"),\n                        Latitude=ei.get(\"Latitude\"),\n                        Longitude=ei.get(\"Longitude\"),\n                        SMSAddress=ei.get(\"SMSAddress\"),\n                        MMSAddress=ei.get(\"MMSAddress\"),\n                        PortedInfo=ported_info_list,\n                        NoteCodes=ei.get(\"NoteCodes\", []),\n                        NoteDescriptions=ei.get(\"NoteDescriptions\", [])\n                    ))\n\n        return PE2Response(\n            ExchangeInfoResults=exchange_info_results,\n            Error=error\n        )\n\n    except requests.RequestException as req_exc:\n        # Network or HTTP-level error occurred\n        if is_live:\n            try:\n                # Fallback to backup URL\n                response = requests.get(backup_url, params=params, timeout=10)\n                response.raise_for_status()\n                data = response.json()\n                if \"Error\" in data:\n                    raise RuntimeError(f\"Phone Exchange backup error: {data['Error']}\") from req_exc\n\n                error = Error(**data.get(\"Error\", {})) if data.get(\"Error\") else None\n                exchange_info_results = []\n                if \"ExchangeInfoResults\" in data:\n                    for ei in data.get(\"ExchangeInfoResults\", []):\n                        if isinstance(ei, dict):\n                            ported_info_list = []\n                            if \"PortedInfo\" in ei and ei.get(\"PortedInfo\"):\n                                for pi in ei.get(\"PortedInfo\", []):\n                                    if isinstance(pi, dict):\n                                        ported_info_list.append(PortedInfo(\n                                            OriginalName=pi.get(\"OriginalName\"),\n                                            OriginalLineType=pi.get(\"OriginalLineType\"),\n                                            PortedDate=pi.get(\"PortedDate\"),\n                                            LATA=pi.get(\"LATA\")\n                                        ))\n                            exchange_info_results.append(ExchangeInfo(\n                                PhoneNumber=ei.get(\"PhoneNumber\"),\n                                Name=ei.get(\"Name\"),\n                                City=ei.get(\"City\"),\n                                State=ei.get(\"State\"),\n                                Country=ei.get(\"Country\"),\n                                LineType=ei.get(\"LineType\"),\n                                TimeZone=ei.get(\"TimeZone\"),\n                                Latitude=ei.get(\"Latitude\"),\n                                Longitude=ei.get(\"Longitude\"),\n                                SMSAddress=ei.get(\"SMSAddress\"),\n                                MMSAddress=ei.get(\"MMSAddress\"),\n                                PortedInfo=ported_info_list,\n                                NoteCodes=ei.get(\"NoteCodes\", []),\n                                NoteDescriptions=ei.get(\"NoteDescriptions\", [])\n                            ))\n                return PE2Response(\n                    ExchangeInfoResults=exchange_info_results,\n                    Error=error\n                )\n            except Exception as backup_exc:\n                raise RuntimeError(\"Phone Exchange service unreachable on both endpoints\") from backup_exc\n        else:\n            raise RuntimeError(f\"Phone Exchange trial error: {str(req_exc)}\") from req_exc\n\n\n\nfrom asyncio.windows_events import NULL\nfrom dataclasses import dataclass\nfrom typing import Optional, List, Type\n\n@dataclass\nclass Error:\n    Desc: Optional[str] = None\n    TypeCode: Optional[str] = None\n    DescCode: Optional[str] = None\n    Type: Optional[str] = None\n\n    def __str__(self) -> str:\n        return f\"Error: Desc={self.Desc}, TypeCode={self.TypeCode}, DescCode={self.DescCode}, Type={self.Type}\"\n\n@dataclass\nclass PortedInfo:\n    OriginalName: Optional[str] = None\n    OriginalLineType: Optional[str] = None\n    PortedDate: Optional[str] = None\n    LATA: Optional[str] = None\n\n    def __str__(self) -> str:\n        return (f\"PortedInfo: OriginalName={self.OriginalName}, OriginalLineType={self.OriginalLineType}, \"\n                f\"PortedDate={self.PortedDate}, LATA={self.LATA}\")\n\n@dataclass\nclass ExchangeInfo:\n    PhoneNumber: Optional[str] = None\n    Name: Optional[str] = None\n    City: Optional[str] = None\n    State: Optional[str] = None\n    Country: Optional[str] = None\n    LineType: Optional[str] = None\n    TimeZone: Optional[str] = None\n    Latitude: Optional[str] = None\n    Longitude: Optional[str] = None\n    SMSAddress: Optional[str] = None\n    MMSAddress: Optional[str] = None\n    PortedInfo: Optional['PortedInfo'] = None\n    NoteCodes: Optional[str] = None\n    NoteDescriptions: Optional[str] = None\n\n    def __post_init__(self):\n        if self.NoteCodes is None:\n            self.NoteCodes = \"\"\n        if self.NoteDescriptions is None:\n            self.NoteDescriptions = \"\"\n\n    def __str__(self) -> str:\n        return (f\"ExchangeInfo: PhoneNumber={self.PhoneNumber}, Name={self.Name}, City={self.City}, \"\n                f\"State={self.State}, Country={self.Country}, LineType={self.LineType}, \"\n                f\"TimeZone={self.TimeZone}, Latitude={self.Latitude}, Longitude={self.Longitude}, \"\n                f\"SMSAddress={self.SMSAddress}, MMSAddress={self.MMSAddress}, \"\n                f\"PortedInfo={self.PortedInfo}, NoteCodes=[{self.NoteCodes}], \"\n                f\"NoteDescriptions={self.NoteDescriptions}\")\n\n@dataclass\nclass InternationalExchangeInfo:\n    PhoneNumberIn: Optional[str] = None\n    CountryCode: Optional[str] = None\n    FormatNational: Optional[str] = None\n    Extension: Optional[str] = None\n    Locality: Optional[str] = None\n    LocalityMatchLevel: Optional[str] = None\n    TimeZone: Optional[str] = None\n    Latitude: Optional[str] = None\n    Longitude: Optional[str] = None\n    Country: Optional[str] = None\n    CountryISO2: Optional[str] = None\n    CountryISO3: Optional[str] = None\n    FormatInternational: Optional[str] = None\n    FormatE164: Optional[str] = None\n    Carrier: Optional[str] = None\n    LineType: Optional[str] = None\n    SMSAddress: Optional[str] = None\n    MMSAddress: Optional[str] = None\n    IsValid: bool = False\n    IsValidForRegion: bool = False\n    NoteCodes: Optional[str] = None\n    NoteDescriptions: Optional[str] = None\n\n    def __post_init__(self):\n        if self.NoteCodes is None:\n            self.NoteCodes = \"\"\n        if self.NoteDescriptions is None:\n            self.NoteDescriptions = \"\"\n\n    def __str__(self) -> str:\n        return (f\"InternationalExchangeInfo: PhoneNumberIn={self.PhoneNumberIn}, CountryCode={self.CountryCode}, \"\n                f\"FormatNational={self.FormatNational}, Extension={self.Extension}, Locality={self.Locality}, \"\n                f\"LocalityMatchLevel={self.LocalityMatchLevel}, TimeZone={self.TimeZone}, \"\n                f\"Latitude={self.Latitude}, Longitude={self.Longitude}, Country={self.Country}, \"\n                f\"CountryISO2={self.CountryISO2}, CountryISO3={self.CountryISO3}, \"\n                f\"FormatInternational={self.FormatInternational}, FormatE164={self.FormatE164}, \"\n                f\"Carrier={self.Carrier}, LineType={self.LineType}, SMSAddress={self.SMSAddress}, \"\n                f\"MMSAddress={self.MMSAddress}, IsValid={self.IsValid}, IsValidForRegion={self.IsValidForRegion}, \"\n                f\"NoteCodes={self.NoteCodes}, NoteDescriptions={self.NoteDescriptions}\")\n\n@dataclass\nclass PE2Response:\n    ExchangeInfoResults: Optional[List['ExchangeInfo']] = None\n    InternationalExchangeInfo: Optional['InternationalExchangeInfo'] = None\n    Error: Optional['Error'] = None\n\n    def __post_init__(self):\n        if self.ExchangeInfoResults is None:\n            self.ExchangeInfoResults = []\n\n    def __str__(self) -> str:\n        exchange_info_str = '\\n'.join(str(r) for r in self.ExchangeInfoResults) if self.ExchangeInfoResults else 'None'\n        error_str = str(self.Error) if self.Error else 'None'\n        return (f\"PE2Response: ExchangeInfoResults=[\\n{exchange_info_str}\\n], \"\n                f\"InternationalExchangeInfo=\\n{self.InternationalExchangeInfo}\\n, Error={error_str}\")<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Phone Exchange NodeJS<\/strong> <strong>Rest Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import axios from 'axios';\nimport querystring from 'querystring';\nimport {PE2Response} from '.\/pe2_response.js';\n\n\/**\n * @constant\n * @type {string}\n * @description The base URL for the live ServiceObjects Phone Exchange (PE2) API service.\n *\/\nconst LiveBaseUrl = 'https:\/\/sws.serviceobjects.com\/pe2\/web.svc\/json\/';\n\n\/**\n * @constant\n * @type {string}\n * @description The base URL for the backup ServiceObjects Phone Exchange (PE2) API service.\n *\/\nconst BackupBaseUrl = 'https:\/\/swsbackup.serviceobjects.com\/pe2\/web.svc\/json\/';\n\n\/**\n * @constant\n * @type {string}\n * @description The base URL for the trial ServiceObjects Phone Exchange (PE2) API service.\n *\/\nconst TrialBaseUrl = 'https:\/\/trial.serviceobjects.com\/pe2\/web.svc\/json\/';\n\n\/**\n * &lt;summary>\n * Checks if a response from the API is valid by verifying that it either has no Error object\n * or the Error.TypeCode is not equal to '3'.\n * &lt;\/summary>\n * &lt;param name=\"response\" type=\"Object\">The API response object to validate.&lt;\/param>\n * &lt;returns type=\"boolean\">True if the response is valid, false otherwise.&lt;\/returns>\n *\/\nconst isValid = (response) => !response?.Error || response.Error.TypeCode !== '3';\n\n\/**\n * &lt;summary>\n * Constructs a full URL for the GetExchangeInfo API endpoint by combining the base URL\n * with query parameters derived from the input parameters.\n * &lt;\/summary>\n * &lt;param name=\"params\" type=\"Object\">An object containing all the input parameters.&lt;\/param>\n * &lt;param name=\"baseUrl\" type=\"string\">The base URL for the API service (live, backup, or trial).&lt;\/param>\n * &lt;returns type=\"string\">The constructed URL with query parameters.&lt;\/returns>\n *\/\nconst buildUrl = (params, baseUrl) =>\n    `${baseUrl}GetExchangeInfo?${querystring.stringify(params)}`;\n\n\/**\n * &lt;summary>\n * Performs an HTTP GET request to the specified URL with a given timeout.\n * &lt;\/summary>\n * &lt;param name=\"url\" type=\"string\">The URL to send the GET request to.&lt;\/param>\n * &lt;param name=\"timeoutSeconds\" type=\"number\">The timeout duration in seconds for the request.&lt;\/param>\n * &lt;returns type=\"Promise&lt;PE2Response>\">A promise that resolves to a PE2Response object containing the API response data.&lt;\/returns>\n * &lt;exception cref=\"Error\">Thrown if the HTTP request fails, with a message detailing the error.&lt;\/exception>\n *\/\nconst httpGet = async (url, timeoutSeconds) => {\n    try {\n        const response = await axios.get(url, { timeout: timeoutSeconds * 1000 });\n        return new PE2Response(response.data);\n    } catch (error) {\n        throw new Error(`HTTP request failed: ${error.message}`);\n    }\n};\n\n\/**\n * &lt;summary>\n * Provides functionality to call the ServiceObjects Phone Exchange (PE2) API's GetExchangeInfo endpoint,\n * retrieving phone exchange information (e.g., carrier, line type, ported status) for a given US\/Canada phone number\n * with fallback to a backup endpoint for reliability in live mode.\n * &lt;\/summary>\n *\/\nconst GetExchangeInfoClient = {\n    \/**\n     * &lt;summary>\n     * Asynchronously invokes the GetExchangeInfo API endpoint, attempting the primary endpoint\n     * first and falling back to the backup if the response is invalid (Error.TypeCode == '3') in live mode.\n     * &lt;\/summary>\n     * @param {string} PhoneNumber - The phone number to validate (e.g., \"1234567890\").\n     * @param {string} LicenseKey - Your license key to use the service.\n     * @param {boolean} isLive - Value to determine whether to use the live or trial servers.\n     * @param {number} timeoutSeconds - Timeout, in seconds, for the call to the service.\n     * @returns {Promise&lt;PE2Response>} - A promise that resolves to a PE2Response object.\n     *\/\n    async invokeAsync(PhoneNumber, LicenseKey, isLive = true, timeoutSeconds = 15) {\n        const params = {\n            PhoneNumber,\n            LicenseKey\n        };\n\n        const url = buildUrl(params, isLive ? LiveBaseUrl : TrialBaseUrl);\n        let response = await httpGet(url, timeoutSeconds);\n\n        if (isLive &amp;&amp; !isValid(response)) {\n            const fallbackUrl = buildUrl(params, BackupBaseUrl);\n            const fallbackResponse = await httpGet(fallbackUrl, timeoutSeconds);\n            return fallbackResponse;\n        }\n        return response;\n    },\n\n    \/**\n     * &lt;summary>\n     * Synchronously invokes the GetExchangeInfo API endpoint by wrapping the async call\n     * and awaiting its result immediately.\n     * &lt;\/summary>\n     * @param {string} PhoneNumber - The phone number to validate (e.g., \"1234567890\").\n     * @param {string} LicenseKey - Your license key to use the service.\n     * @param {boolean} isLive - Value to determine whether to use the live or trial servers.\n     * @param {number} timeoutSeconds - Timeout, in seconds, for the call to the service.\n     * @returns {PE2Response} - A PE2Response object with phone exchange details or an error.\n     *\/\n    invoke(PhoneNumber, LicenseKey, isLive = true, timeoutSeconds = 15) {\n        return (async () => await this.invokeAsync(\n            PhoneNumber, LicenseKey, isLive, timeoutSeconds\n        ))();\n    }\n};\n\nexport { GetExchangeInfoClient, PE2Response };\n\n\nexport class ExchangeInfo {\n    constructor(data = {}) {\n        this.PhoneNumber = data.PhoneNumber;\n        this.Name = data.Name;\n        this.City = data.City;\n        this.State = data.State;\n        this.Country = data.Country;\n        this.LineType = data.LineType;\n        this.TimeZone = data.TimeZone;\n        this.Latitude = data.Latitude;\n        this.Longitude = data.Longitude;\n        this.SMSAddress = data.SMSAddress;\n        this.MMSAddress = data.MMSAddress;\n        this.PortedInfo = data.PortedInfo;\n        this.NoteCodes = data.NoteCodes;\n        this.NoteDescriptions = data.NoteDescriptions;\n    }\n\n    toString() {\n        return `ExchangeInfo: PhoneNumber = ${this.PhoneNumber}, Name = ${this.Name}, City = ${this.City}, State = ${this.State}, Country = ${this.Country}, LineType = ${this.LineType}, TimeZone = ${this.TimeZone}, Latitude = ${this.Latitude}, Longitude = ${this.Longitude}, SMSAddress = ${this.SMSAddress}, MMSAddress = ${this.MMSAddress}, PortedInfo = ${this.PortedInfo}, NoteCodes = ${this.NoteCodes}, NoteDescriptions = ${this.NoteDescriptions}`;\n    }\n}\n\n\/**\n * Ported information for a phone number.\n *\/\nexport class PortedInfo {\n    constructor(data = {}) {\n        this.OriginalName = data.OriginalName;\n        this.OriginalLineType = data.OriginalLineType;\n        this.PortedDate = data.PortedDate;\n        this.LATA = data.LATA;\n    }\n\n    toString() {\n        return `PortedInfo: OriginalName = ${this.OriginalName}, OriginalLineType = ${this.OriginalLineType}, PortedDate = ${this.PortedDate}, LATA = ${this.LATA}`;\n    }\n}\n\n\/**\n * International phone exchange information for a validated phone number.\n *\/\nexport class InternationalExchangeInfo {\n    constructor(data = {}) {\n        this.PhoneNumberIn = data.NumberIn;\n        this.CountryCode = data.CountryCode;\n        this.FormatNational = data.FormatNational;\n        this.Extension = data.Extension;\n        this.Locality = data.Locality;\n        this.LocalityMatchLevel = data.LocalityMatchLevel;\n        this.TimeZone = data.TimeZone;\n        this.Latitude = data.Latitude;\n        this.Longitude = data.Longitude;\n        this.Country = data.Country;\n        this.CountryISO2 = data.CountryISO2;\n        this.CountryISO3 = data.CountryISO3;\n        this.FormatInternational = data.FormatInternational;\n        this.FormatE164 = data.FormatE164;\n        this.Carrier = data.Carrier;\n        this.LineType = data.LineType;\n        this.SMSAddress = data.SMSAddress;\n        this.MMSAddress = data.MMSAddress;\n        this.IsValid = data.IsValid !== undefined ? data.IsValid : null;\n        this.IsValidForRegion = data.IsValidForRegion !== undefined ? data.IsValidForRegion : null;\n        this.NoteCodes = data.NoteCodes;\n        this.NoteDescriptions = data.NoteDescriptions;\n    }\n\n    toString() {\n        return `InternationalExchangeInfo: PhoneNumberIn = ${this.PhoneNumberIn}, CountryCode = ${this.CountryCode}, FormatNational = ${this.FormatNational}, Extension = ${this.Extension}, Locality = ${this.Locality}, LocalityMatchLevel = ${this.LocalityMatchLevel}, TimeZone = ${this.TimeZone}, Latitude = ${this.Latitude}, Longitude = ${this.Longitude}, Country = ${this.Country}, CountryISO2 = ${this.CountryISO2}, CountryISO3 = ${this.CountryISO3}, FormatInternational = ${this.FormatInternational}, FormatE164 = ${this.FormatE164}, Carrier = ${this.Carrier}, LineType = ${this.LineType}, SMSAddress = ${this.SMSAddress}, MMSAddress = ${this.MMSAddress}, IsValid = ${this.IsValid}, IsValidForRegion = ${this.IsValidForRegion}, NoteCodes = ${this.NoteCodes}, NoteDescriptions = ${this.NoteDescriptions}`;\n    }\n}\n\n\/**\n * Error object for PE2 API responses.\n *\/\nexport class Error {\n    constructor(data = {}) {\n        this.Desc = data.Desc;\n        this.TypeCode = data.TypeCode;\n        this.DescCode = data.DescCode;\n        this.Type = data.Type;\n    }\n\n    toString() {\n        return `Error: Desc = ${this.Desc}, TypeCode = ${this.TypeCode}, DescCode = ${this.DescCode}, Type= ${this.Type}}`;\n    }\n}\n\n\/**\n * Response from PE2 GetExchangeInfo and GetInternationalExchangeInfo APIs, containing phone exchange information.\n *\/\nexport class PE2Response {\n    constructor(data = {}) {\n        this.ExchangeInfo = Array.isArray(data.ExchangeInfoResults)\n            ? data.ExchangeInfoResults.map(info => new ExchangeInfo(info))\n            : [];\n        this.ExchangeInfoResults = (data.ExchangeInfoResults || []).map(info => new ExchangeInfo(info));\n        this.InternationalExchangeInfo = data.InternationalExchangeInfo ? new InternationalExchangeInfo(data.InternationalExchangeInfo) : null;\n        this.Error = data.Error ? new Error(data.Error) : null;\n    }\n\n    toString() {\n        const exchangeInfoString = this.ExchangeInfoResults.length\n            ? this.ExchangeInfoResults.map(info => info.toString()).join('; ')\n            : 'null';\n        const internationalInfoString = this.InternationalExchangeInfo.length\n            ? this.InternationalExchangeInfo.map(info => info.toString()).join('; ')\n            : 'null';\n        return `PE2Response: ExchangeInfoResults = [${exchangeInfoString}], InternationalExchangeInfo = [${internationalInfoString}], Error = ${this.Error ? this.Error.toString() : 'null'}`;\n    }\n}\n\nexport default PE2Response;<\/pre>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":5198,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5228","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PE2 - REST<\/title>\n<meta name=\"description\" content=\"C#PythonNodeJS Phone Exchange C# Rest Code Snippet \ufeff using System.Web; namespace phone_exchange_2_dot_net.REST { \/\/\/ &lt;summary&gt; \/\/\/ Provides\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PE2 - REST\" \/>\n<meta property=\"og:description\" content=\"C#PythonNodeJS Phone Exchange C# Rest Code Snippet \ufeff using System.Web; namespace phone_exchange_2_dot_net.REST { \/\/\/ &lt;summary&gt; \/\/\/ Provides\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/\" \/>\n<meta property=\"og:site_name\" content=\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-26T20:23:40+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/\",\"url\":\"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/\",\"name\":\"PE2 - REST\",\"isPartOf\":{\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#website\"},\"datePublished\":\"2022-11-14T02:30:37+00:00\",\"dateModified\":\"2025-09-26T20:23:40+00:00\",\"description\":\"C#PythonNodeJS Phone Exchange C# Rest Code Snippet \ufeff using System.Web; namespace phone_exchange_2_dot_net.REST { \/\/\/ &lt;summary> \/\/\/ Provides\",\"breadcrumb\":{\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.serviceobjects.com\/docs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DOTS Phone Exchange 2\",\"item\":\"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PE2 &#8211; Code Snippets and Sample Code\",\"item\":\"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"PE2 &#8211; REST\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#website\",\"url\":\"https:\/\/www.serviceobjects.com\/docs\/\",\"name\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.serviceobjects.com\/docs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#organization\",\"name\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\",\"url\":\"https:\/\/www.serviceobjects.com\/docs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png\",\"contentUrl\":\"https:\/\/www.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png\",\"width\":2560,\"height\":1440,\"caption\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\"},\"image\":{\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PE2 - REST","description":"C#PythonNodeJS Phone Exchange C# Rest Code Snippet \ufeff using System.Web; namespace phone_exchange_2_dot_net.REST { \/\/\/ &lt;summary> \/\/\/ Provides","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/","og_locale":"en_US","og_type":"article","og_title":"PE2 - REST","og_description":"C#PythonNodeJS Phone Exchange C# Rest Code Snippet \ufeff using System.Web; namespace phone_exchange_2_dot_net.REST { \/\/\/ &lt;summary> \/\/\/ Provides","og_url":"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/","og_site_name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","article_modified_time":"2025-09-26T20:23:40+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/","url":"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/","name":"PE2 - REST","isPartOf":{"@id":"https:\/\/www.serviceobjects.com\/docs\/#website"},"datePublished":"2022-11-14T02:30:37+00:00","dateModified":"2025-09-26T20:23:40+00:00","description":"C#PythonNodeJS Phone Exchange C# Rest Code Snippet \ufeff using System.Web; namespace phone_exchange_2_dot_net.REST { \/\/\/ &lt;summary> \/\/\/ Provides","breadcrumb":{"@id":"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/pe2-rest\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.serviceobjects.com\/docs\/"},{"@type":"ListItem","position":2,"name":"DOTS Phone Exchange 2","item":"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/"},{"@type":"ListItem","position":3,"name":"PE2 &#8211; Code Snippets and Sample Code","item":"https:\/\/www.serviceobjects.com\/docs\/dots-phone-exchange-2\/pe2-code-snippets-and-sample-code\/"},{"@type":"ListItem","position":4,"name":"PE2 &#8211; REST"}]},{"@type":"WebSite","@id":"https:\/\/www.serviceobjects.com\/docs\/#website","url":"https:\/\/www.serviceobjects.com\/docs\/","name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","description":"","publisher":{"@id":"https:\/\/www.serviceobjects.com\/docs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.serviceobjects.com\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.serviceobjects.com\/docs\/#organization","name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","url":"https:\/\/www.serviceobjects.com\/docs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.serviceobjects.com\/docs\/#\/schema\/logo\/image\/","url":"https:\/\/www.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png","contentUrl":"https:\/\/www.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png","width":2560,"height":1440,"caption":"Service Objects | Contact, Phone, Email Verification | Data Quality Services"},"image":{"@id":"https:\/\/www.serviceobjects.com\/docs\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/5228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/comments?post=5228"}],"version-history":[{"count":11,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/5228\/revisions"}],"predecessor-version":[{"id":12336,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/5228\/revisions\/12336"}],"up":[{"embeddable":true,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/5198"}],"wp:attachment":[{"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/media?parent=5228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}