### Claris Studio OData Integration Example (C#) Source: https://help.claris.com/en/odata-guide/content/query-option-filter This C# code snippet demonstrates a basic integration with an OData service using Claris Studio. It outlines how to establish a connection and retrieve data. Ensure the necessary OData client libraries are installed. ```csharp using System; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; public class ODataClient { private readonly HttpClient _httpClient; private readonly string _baseUrl; public ODataClient(string baseUrl) { _httpClient = new HttpClient(); _baseUrl = baseUrl; _httpClient.DefaultRequestHeaders.Accept.Clear(); _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } public async Task GetDataAsync(string entitySet) { try { HttpResponseMessage response = await _httpClient.GetAsync($"{_baseUrl}/{entitySet}"); response.EnsureSuccessStatusCode(); // Throw if not success return await response.Content.ReadAsStringAsync(); } catch (HttpRequestException e) { Console.WriteLine($"Error fetching data: {e.Message}"); return null; } } // Add methods for POST, PUT, DELETE as needed } public class Program { public static async Task Main(string[] args) { string odataServiceUrl = "YOUR_ODATA_SERVICE_URL"; // Replace with your OData service URL ODataClient client = new ODataClient(odataServiceUrl); // Example: Get data from an entity set named "Products" string productsData = await client.GetDataAsync("Products"); if (productsData != null) { Console.WriteLine("Products Data:"); Console.WriteLine(productsData); } else { Console.WriteLine("Failed to retrieve products data."); } } } ``` -------------------------------- ### OData Query Example Source: https://help.claris.com/en/odata-guide/content/query-option-select Demonstrates how to construct a basic OData query to retrieve data. This example focuses on GET requests and filtering. ```odata GET /api/v2/data/Customers?$filter=Country eq 'USA' ``` -------------------------------- ### C# HttpClient for OData Source: https://help.claris.com/en/odata-guide/content/query-option-select Provides an example of using C# HttpClient to consume OData services. This demonstrates making GET requests and deserializing JSON responses. ```csharp using System.Net.Http; using System.Threading.Tasks; using System.Text.Json; public class ODataClient { private readonly HttpClient _httpClient; public ODataClient(HttpClient httpClient) { _httpClient = httpClient; _httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); } public async Task GetCustomersAsync() { var response = await _httpClient.GetAsync("/api/v2/data/Customers"); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); return JsonSerializer.Deserialize(json); } } public class Customer { public int Id { get; set; } public string Name { get; set; } public string Country { get; set; } } ``` -------------------------------- ### Claris Connect OData Guide: Authentication and Connection Examples Source: https://help.claris.com/en/odata-guide/content/write-odata-api-calls This snippet demonstrates how to establish a connection and authenticate with Claris Connect using OData. It includes examples for common programming languages, showcasing the necessary steps to initiate a connection and handle authentication tokens. Ensure you have the correct API keys and endpoint URLs for successful integration. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class ClarisConnectOData { private readonly string _baseUrl; private readonly string _apiKey; public ClarisConnectOData(string baseUrl, string apiKey) { _baseUrl = baseUrl; _apiKey = apiKey; } public async Task GetDataAsync(string entitySet) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(_baseUrl); client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_apiKey}"); var response = await client.GetAsync($"/{entitySet}"); response.EnsureSuccessStatusCode(); return await response.Content.ReadAsStringAsync(); } } // Example usage: // public static async Task Main(string[] args) { // var connector = new ClarisConnectOData("https://api.clarisconnect.com/v1", "YOUR_API_KEY"); // var data = await connector.GetDataAsync("your_entity_set"); // Console.WriteLine(data); // } } ``` ```javascript async function getClarisConnectData(baseUrl, apiKey, entitySet) { const url = `${baseUrl}/${entitySet}`; try { const response = await fetch(url, { method: 'GET', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return await response.json(); } catch (error) { console.error('Error fetching data from Claris Connect:', error); throw error; } } // Example usage: // const BASE_URL = 'https://api.clarisconnect.com/v1'; // const API_KEY = 'YOUR_API_KEY'; // getClarisConnectData(BASE_URL, API_KEY, 'your_entity_set') // .then(data => console.log(data)) // .catch(err => console.error('Failed to get data')); ``` -------------------------------- ### OData Query Example Source: https://help.claris.com/en/odata-guide/content/run-scripts Demonstrates how to construct a basic OData query to retrieve data. This example is language-agnostic, representing a common query pattern. ```odata GET /api/v1/customers?$filter=City eq 'London'&$select=CustomerID,CompanyName,ContactName ``` -------------------------------- ### OData POST Request Example Source: https://help.claris.com/en/odata-guide/content/query-option-select Demonstrates how to create a new resource using an OData POST request. This includes setting the appropriate headers and providing the data in the request body. ```odata POST /api/v2/data/Customers Content-Type: application/json { "Name": "New Customer", "Country": "Canada" } ``` -------------------------------- ### Query OData Service with cURL Source: https://help.claris.com/en/odata-guide/content/index This example shows how to query an OData service using cURL, a command-line tool for transferring data. It covers making GET requests to retrieve data and includes handling authentication. ```Shell # Define OData service URL and authentication details ODATA_URL="https://your-odata-service.com/odata" USERNAME="admin" PASSWORD="password" # Construct the authorization header AUTH_HEADER="-u $USERNAME:$PASSWORD" # Make a GET request to retrieve 'Customers' data curl -X GET "$ODATA_URL/Customers" $AUTH_HEADER -H "Accept: application/json" ``` -------------------------------- ### C# OData Client Example Source: https://help.claris.com/en/odata-guide/content/run-scripts Illustrates how to use a C# client to interact with an OData service, including setting up the service URI and making a query. Requires the OData client libraries. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; using Microsoft.OData.Client; public class ODataClientExample { public static async Task QueryCustomersAsync(string serviceUri) { var container = new DefaultContainer(new Uri(serviceUri)); container.Credentials = new System.Net.NetworkCredential("user", "password"); // Example credentials var customers = container.Customers.AddQueryOption("$filter", "City eq 'London'") .AddQueryOption("$select", "CustomerID,CompanyName,ContactName"); var result = await customers.ExecuteAsync(); foreach (var customer in result) { Console.WriteLine($"ID: {customer.CustomerID}, Name: {customer.CompanyName}"); } } } ``` -------------------------------- ### Example C# OData Query for Claris FileMaker Source: https://help.claris.com/en/odata-guide/content/delete-table This C# code demonstrates how to construct a basic OData query to retrieve data from a Claris FileMaker OData endpoint. It shows how to specify filters, select specific fields, and order the results. Ensure you have the necessary OData client libraries installed. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class ODataClient { public async Task GetODataData(string serviceRootUrl, string entitySetPath) { using (var client = new HttpClient()) { // Construct the OData query URL // Example: $filter=Status eq 'Active'&$select=Name,ID&$orderby=Name asc string query = $"/{entitySetPath}?$filter=Status eq 'Active'&$select=Name,ID&$orderby=Name asc"; string requestUri = serviceRootUrl.TrimEnd('/') + query; try { HttpResponseMessage response = await client.GetAsync(requestUri); response.EnsureSuccessStatusCode(); // Throw an exception if the status code is not successful string responseBody = await response.Content.ReadAsStringAsync(); return responseBody; } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); return null; } } } public static async Task Main(string[] args) { var client = new ODataClient(); string serviceUrl = "https://your.filemaker.server/fmi/odata/api/YOUR_DATABASE"; // Replace with your service root URL string entity = "YOUR_ENTITY_SET"; // Replace with your entity set name string data = await client.GetODataData(serviceUrl, entity); if (data != null) { Console.WriteLine("OData Response:"); Console.WriteLine(data); } } } ``` -------------------------------- ### JavaScript OData Fetch Example Source: https://help.claris.com/en/odata-guide/content/run-scripts Shows a JavaScript snippet for fetching data from an OData endpoint using the Fetch API. This is useful for web-based applications. ```javascript async function fetchCustomers(serviceUri) { const filter = "City eq 'London'"; const select = "CustomerID,CompanyName,ContactName"; const url = `${serviceUri}/customers?$filter=${encodeURIComponent(filter)}&$select=${encodeURIComponent(select)}`; try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log(data.value); return data.value; } catch (error) { console.error('Error fetching customers:', error); } } ``` -------------------------------- ### Claris OData API - Fetching Data Source: https://help.claris.com/en/odata-guide/content/api-solution-comparison Demonstrates how to fetch data from a Claris OData service using HTTP requests. This example uses Python and the 'requests' library to interact with the OData API. ```Python import requests url = "https://your.claris.server/fmi/data/v1/OData/your_database/Contacts?$filter=City='New York'&$select=Name,Email" headers = { "Authorization": "Basic YOUR_BASE64_ENCODED_CREDENTIALS", "Content-Type": "application/json" } response = requests.get(url, headers=headers) if response.status_code == 200: data = response.json() print(data) else: print(f"Error: {response.status_code}") print(response.text) ``` -------------------------------- ### OData Query Example for Retrieving Data Source: https://help.claris.com/en/odata-guide/content/modify-schema This example demonstrates a basic OData query to retrieve data. It specifies the entity set to query and applies a filter to narrow down the results. The query assumes a dataset with 'CustomerID' and 'CompanyName' fields. ```odata GET /odata/Customers?$filter=CompanyName eq 'Around the Horn' ``` -------------------------------- ### FileMaker Server Authentication Source: https://help.claris.com/en/odata-guide/content/creating-authenticated-connection Provides instructions and examples for authenticating with FileMaker Server using OData API URLs and the Authorization header with Basic authentication. ```APIDOC ## FileMaker Server Authentication ### Description Authenticates to a hosted FileMaker database using OData API URLs and the `Authorization` header with Base64-encoded account credentials. ### Method GET (for metadata retrieval, other methods may apply for data operations) ### Endpoint `https://host/fmi/odata/v4/database-name/$metadata` ### Parameters #### Path Parameters - **host** (string) - Required - The FileMaker Server host name. - **database-name** (string) - Required - The FileMaker Pro database name. #### Query Parameters None #### Request Body None ### Request Example ``` GET https://your.filemaker.server.com/fmi/odata/v4/MyDatabase/$metadata Authorization: Basic YWRtaW46YWRtaW4= ``` ### Response #### Success Response (200) - **Metadata**: The OData service metadata document describing the database schema. #### Response Example ```json { "@odata.context": "https://your.filemaker.server.com/fmi/odata/v4/MyDatabase/$metadata#$types", "value": [ { "name": "Customers", "kind": "entityContainer" } ] } ``` ``` -------------------------------- ### Retrieve Data with ODATA using C# Source: https://help.claris.com/en/odata-guide/content/update-record-references This C# code snippet demonstrates how to retrieve data from an ODATA service. It utilizes the `HttpClient` class to make a GET request to the specified ODATA endpoint. Ensure the necessary NuGet packages (e.g., `System.Net.Http`) are installed. The output is the JSON response from the ODATA service. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class OdataClient { public async Task GetDataAsync(string serviceUrl) { using (HttpClient client = new HttpClient()) { try { HttpResponseMessage response = await client.GetAsync(serviceUrl); response.EnsureSuccessStatusCode(); // Throw an exception if the status code is not success string responseBody = await response.Content.ReadAsStringAsync(); return responseBody; } catch (HttpRequestException e) { Console.WriteLine($"\nException Caught: {e.Message}"); return null; } } } // Example usage: // static async Task Main(string[] args) // { // OdataClient client = new OdataClient(); // string data = await client.GetDataAsync("http://services.odata.org/V4/TripPinServiceRW/People"); // Console.WriteLine(data); // } } ``` -------------------------------- ### Create and Update OData Records (JavaScript) Source: https://help.claris.com/en/odata-guide/content/get-database-names Provides JavaScript examples for creating new OData records and updating existing ones. It shows how to construct the request body with the necessary fields and specifies the HTTP method (POST for create, PATCH for update). ```javascript // Create a new record fetch('/odata/SalesOrder', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ CustomerName: 'New Customer', OrderDate: '2023-10-27' }) }) .then(response => response.json()) .then(data => console.log('Created:', data)) .catch(error => console.error('Error creating record:', error)); // Update an existing record const orderIdToUpdate = '123'; // Replace with actual Order ID fetch(`/odata/SalesOrder(${orderIdToUpdate})`, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ OrderDate: '2023-10-28' }) }) .then(response => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } console.log('Updated successfully'); }) .catch(error => console.error('Error updating record:', error)); ``` -------------------------------- ### JavaScript OData Authentication Example Source: https://help.claris.com/en/odata-guide/content/run-scripts This snippet demonstrates how to authenticate with an OData service using JavaScript. It typically involves setting up headers with authentication tokens or credentials. This method is crucial for secure access to OData endpoints. ```javascript function getODataWithAuth(url, token) { return fetch(url, { method: 'GET', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' } }).then(response => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); }); } ``` -------------------------------- ### Claris Connect Dropdown Icon Example Source: https://help.claris.com/en/odata-guide/content/query-option-expand This snippet demonstrates how to implement the Claris Connect dropdown icon for navigation. It uses CSS to style the icon and specifies the background image source. ```css .cs-globalnav .cs-main-nav .cs-gnav-dropdown-icon-claris-connect{ background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAADwCAYAAAA+VemSAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAA8KADAAQAAAABAAAA8AAAAADV6CrLAAAo0UlEQVR4Ae2dD7AkR33fu2f3dE/SyXmIwz7DYR5w6N7x7k5XpSMIdELPQRXhRImUAGWIlKpLhUoUy4olA7YpO2VRBRFJqcpKTAq7LMVKWRgIR5BAjkRK5E7oDokgFfdHh+6Uc/xMZHshKuWiP+aJ253O79fdv57Z2dnd2d350zP7m7rb3u7pP7/+9u8z3TNvZlYK3hqpwNLB/Quvfa1YClsb3xAotVWqcAk6ukVItSiF3ALfFyV8h3BBYjpsEOoPKRR+05vUiXafSV8LIE0p1ZFSrgdSrSkpzopQdISUnSBUfw4F1w7tuHfN1MCfRSpgh6fIJrjuIhW45Ml/tnlhg7w0EOFOwG45kHIb0LUM4G3FdglA/d2CSWlu8KUy8GJ+kxHC4RBHeTAzloG8tjKqEw4OsEedgR2n4AuE6pSQwTHxk1eePrTy5ZexHG+zK0B6z14T11C4Akvf2794oVx4J8yme2H22wvg7AVAthpYHEMOWoKQgEUDk2nOAUZArPPYjCawwEPEJo+AOJ5HGwAf6gyUOyoCcThQ8slzLfnUoTffu4728TaZAqT/ZKU4dykKILAXiAuvkqK7Cg2uwtJ3DzZMM1588OoGMR1IsD/QoXUNtBKHRFsd6orWowy0VmbsR9wHxmbmDMUrsP17N10R9OT7wKmvhv+XmwEaPuPFB3B2iKGdWIX6K3wQbBRHFUy24XZFeSCvXk5TGRvG6tV5TYXU1jrYcVgJ9Yjs9h74b9u/gMtw3lIUsLKl7OGkUhTAi00bFy+8RvXCa8Fpr4cB2YwN64FxTo0pw2GJD+IALK4Oc07bD2h/msnqDcTuYCIVnEtL+WDQDg889KbPH0E1eDMKxMeeNSlLgYOr7bddtOMapeSH4Iru9dDsJmxaDwZ8TDPjxQcyK8SmTE0g1mODBzH1nArEgQD+M8zWZ7Q2/FG4Am/+zi2XtoJwP8ymN4L0sZnWzq5gAUMMGtijkTuQuTgOUWyFoODqdiDuk111z0Nv+/xzuHfeNivNvHW7vP6+7uAvbbrwAnFDIIOPQKt45Vg3Tk6KEQMtQ0zaaE0ct ``` -------------------------------- ### Create OData Record with Python (Requests) Source: https://help.claris.com/en/odata-guide/content/index This Python example uses the 'requests' library to create a new record in an OData service. It shows how to send a POST request with JSON data and handle the response. ```Python import requests import json odata_url = "https://your-odata-service.com/odata/Orders" username = "admin" password = "password" new_order_data = { "OrderID": 10249, "CustomerID": "ALFKI", "EmployeeID": 5, "OrderDate": "2023-10-27T00:00:00Z", "RequiredDate": "2023-11-24T00:00:00Z", "ShippedDate": None, "ShipVia": 3, "Freight": 32.38, "ShipName": "Alfreds Futterkiste", "ShipAddress": "Obere Str. 57", "ShipCity": "Berlin", "ShipRegion": None, "ShipPostalCode": "12209", "ShipCountry": "Germany" } response = requests.post( odata_url, auth=(username, password), headers={'Content-Type': 'application/json'}, data=json.dumps(new_order_data) ) if response.status_code == 201: print("Order created successfully:") print(response.json()) else: print(f"Error creating order: {response.status_code}") print(response.text) ``` -------------------------------- ### C# OData Client for Claris Connect Source: https://help.claris.com/en/odata-guide/content/update-record-with-container-binary-data This C# code snippet demonstrates how to create an OData client to interact with Claris Connect services. It includes setting up the service URL, authenticating, and performing basic CRUD operations. Note: Ensure you have the necessary OData client libraries installed (e.g., via NuGet). ```csharp using System; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; public class ClarisConnectODataClient { private readonly string _serviceRootUrl; private readonly string _apiKey; public ClarisConnectODataClient(string serviceRootUrl, string apiKey) { _serviceRootUrl = serviceRootUrl; _apiKey = apiKey; } public async Task GetDataAsync(string entitySet) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(_serviceRootUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _apiKey); HttpResponseMessage response = await client.GetAsync($"{entitySet}?$format=json"); response.EnsureSuccessStatusCode(); // Throw if HTTP status is not 2xx return await response.Content.ReadAsStringAsync(); } } // Add methods for POST, PUT, DELETE as needed } // Example Usage: // var client = new ClarisConnectODataClient("YOUR_SERVICE_ROOT_URL", "YOUR_API_KEY"); // var data = await client.GetDataAsync("YourEntitySet"); // Console.WriteLine(data); ``` -------------------------------- ### Python Requests for OData Source: https://help.claris.com/en/odata-guide/content/query-option-select Illustrates how to use the Python 'requests' library to interact with the OData API. This covers sending GET requests and processing JSON responses. ```python import requests url = "/api/v2/data/Customers" headers = { "Accept": "application/json" } response = requests.get(url, headers=headers) if response.status_code == 200: data = response.json() print(data) else: print(f"Error: {response.status_code}") ``` -------------------------------- ### C# OData Query for Claris Studio Source: https://help.claris.com/en/odata-guide/content/query-option-top-skip This C# code snippet demonstrates how to construct a basic OData query to retrieve data from a Claris Studio endpoint. It utilizes the OData client library. Ensure you have the appropriate NuGet packages installed for OData client functionality. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class ODataQueryExample { public static async Task Main(string[] args) { // Replace with your actual OData service URL string odataServiceUrl = "https://your-claris-studio-odata-url/odata"; string entitySetName = "YourEntitySetName"; // e.g., "Customers" using (var client = new HttpClient()) { client.BaseAddress = new Uri(odataServiceUrl); // Construct the OData query URL // Example: $filter=PropertyName eq 'SomeValue'&$select=Id,Name string queryUrl = $"{entitySetName}?$filter=Status eq 'Active'&$select=Id,Name"; try { HttpResponseMessage response = await client.GetAsync(queryUrl); if (response.IsSuccessStatusCode) { string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine("OData Response:"); Console.WriteLine(responseBody); // Further processing of the response data (e.g., deserialization) } else { Console.WriteLine($"Error: {response.StatusCode}"); string errorBody = await response.Content.ReadAsStringAsync(); Console.WriteLine($"Error Details: {errorBody}"); } } catch (Exception ex) { Console.WriteLine($"Exception: {ex.Message}"); } } } } ``` -------------------------------- ### Creating Data with Claris Connect OData Source: https://help.claris.com/en/odata-guide/content/enable-access This example shows how to create new data entries through Claris Connect's OData API. It involves sending POST requests to the appropriate OData collection endpoints with the data payload. This is essential for applications that need to add new records to Claris Connect. ```text POST /data/v1/lists/{listId}/items ``` -------------------------------- ### JavaScript: Making OData Requests Source: https://help.claris.com/en/odata-guide/content/get-metadata This JavaScript snippet shows how to make OData requests using the `fetch` API in a web environment. It covers basic GET requests to retrieve data from an OData endpoint. Error handling for network issues and non-OK responses is included. ```javascript const odataUrl = 'https://your-odata-service.com/odata/YourEntitySet'; async function fetchOData() { try { const response = await fetch(odataUrl, { method: 'GET', headers: { 'Accept': 'application/json' } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); // Process the data console.log(data); } catch (error) { console.error('Error fetching OData:', error); } } fetchOData(); ``` -------------------------------- ### Claris FileMaker: Executing OData Queries Source: https://help.claris.com/en/odata-guide/content/get-metadata This example illustrates how to execute OData queries within Claris FileMaker using the Insert from URL script step. It demonstrates constructing a URL with query options and handling the JSON response. Note that complex OData features might require custom parsing of the JSON result. ```filemaker Set Variable [ $odataServiceURL ; Value: "https://your-odata-service.com/odata/YourEntitySet" ] # Example: Add a filter query option # Set Variable [ $odataQuery ; Value: "?$filter=SomeField eq 'SomeValue'" ] # Set Variable [ $fullURL ; Value: $odataServiceURL & $odataQuery ] # Without query options for simplicity Set Variable [ $fullURL ; Value: $odataServiceURL ] Insert From URL [ $$odataResult ; "" URL: $fullURL Specify data formatting by insert/leftrightarrow: Off Specify cURL options: "-H \"Accept: application/json\"" ] # Process the JSON result stored in $$odataResult using functions like JSONGetElement ``` -------------------------------- ### Claris OData API - Creating Records Source: https://help.claris.com/en/odata-guide/content/api-solution-comparison Shows how to create new records in a Claris OData service using HTTP POST requests. This example uses Python to send JSON data to the OData API. ```Python import requests import json url = "https://your.claris.server/fmi/data/v1/OData/your_database/Contacts" headers = { "Authorization": "Basic YOUR_BASE64_ENCODED_CREDENTIALS", "Content-Type": "application/json" } new_record = { "Name": "John Doe", "Email": "john.doe@example.com", "City": "New York" } response = requests.post(url, headers=headers, data=json.dumps(new_record)) if response.status_code == 201: print("Record created successfully!") print(response.json()) else: print(f"Error: {response.status_code}") print(response.text) ``` -------------------------------- ### Using $count=true in FileMaker OData API GET Request Source: https://help.claris.com/en/odata-guide/content/query-option-count This example demonstrates how to construct a GET request to the FileMaker OData API to include the total count of matching records. It specifies the host, OData version, database name, table name, and the $count=true query option. The $count option will return the total number of records matching the filter criteria, regardless of $top or $skip values. ```http GET https://host/fmi/odata/v4/database-name/table-name?$count=true ``` ```http GET /fmi/odata/v4/ContactMgmt/Contacts?$count=true ``` -------------------------------- ### JavaScript Fetch API for OData Source: https://help.claris.com/en/odata-guide/content/query-option-select Shows how to use the JavaScript Fetch API to make OData requests. This includes setting headers and handling responses. ```javascript fetch('/api/v2/data/Customers', { method: 'GET', headers: { 'Accept': 'application/json' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### OData DELETE Request Example Source: https://help.claris.com/en/odata-guide/content/query-option-select Demonstrates how to delete an existing resource using an OData DELETE request. This requires specifying the resource ID in the URL. ```odata DELETE /api/v2/data/Customers(1) ```