### HTTP GET Request Example (C# HttpClient) Source: https://connhex.com/docs/api/resources/read-type-two-resource-relationship Demonstrates making a GET request to retrieve resources using C#'s HttpClient. It includes setting the Accept and Authorization headers. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./resources/resources/typeTwoResources/:id/relationships/:related_field/"); request.Headers.Add("Accept", "application/vnd.api+json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### List Customers Request Example (C# HttpClient) Source: https://connhex.com/docs/api/pay/list An example of how to make a GET request to the list customers endpoint using C#'s HttpClient. It demonstrates setting up the request, sending it, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./pay/customers"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### HTTP GET Request Example (C#) Source: https://connhex.com/docs/api/auth/create-browser-settings-flow This C# code snippet demonstrates how to make an HTTP GET request to the authentication settings endpoint using HttpClient. It includes setting the Accept header and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://accounts./auth/self-service/settings/browser"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Connhex Mapper Example Configuration Source: https://connhex.com/docs/mapper/configuration An example TOML configuration file for Connhex Mapper, demonstrating the setup for message format, validation, and defining multiple mappers with filters, queries, and subtopics. ```toml format = "JSON" validate = true [[mappers]] filter = "attr0" query = "@toentries" subtopic = "sub0" [[mappers]] filter = "attr1" query = "@tonumber" ``` -------------------------------- ### Fetch User Settings API Example (C# HttpClient) Source: https://connhex.com/docs/api/auth/create-native-settings-flow Demonstrates how to fetch user self-service settings using C#'s HttpClient. It sends a GET request to the specified endpoint and handles the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://accounts./auth/self-service/settings/api"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Establish WebSocket Connection (HTTP) Source: https://connhex.com/docs/api/core/websocket/establishes-web-socket-connection-with-channel-and-subtopic Demonstrates establishing a WebSocket connection using a standard HTTP GET request. This is a foundational example showing the endpoint and required headers for initiating the connection. It does not include specific client-side implementation details. ```http GET wss://apis./iot/ws/channels/:id/messages/:subtopic Authorization: Bearer ``` -------------------------------- ### C# HttpClient Example for Listing Tenants Source: https://connhex.com/docs/api/iam/policies/policies-list-tenants Demonstrates how to use C# HttpClient to make a GET request to the Connhex IAM tenants API. It shows setting up the request, adding headers, sending the request, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./iam/tenants"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Example for Connhex API Source: https://connhex.com/docs/api/resources/read-type-one-resource-relationship Provides a C# example using HttpClient to make a GET request to the Connhex API. It includes setting the Accept header to 'application/vnd.api+json' and the Authorization header with a Bearer token. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./resources/resources/typeOneResources/:id/relationships/:related_field/"); request.Headers.Add("Accept", "application/vnd.api+json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Tenant by ID (Shell) Source: https://connhex.com/docs/api/iam/policies/policies-get-tenant This example shows how to retrieve tenant details using a simple shell command, likely with `curl`. It specifies the HTTP method and the target URL. ```shell curl -X GET "https://apis./iam/tenants/:id" -H "Accept: application/json" ``` -------------------------------- ### Get Tenant by ID (C# HttpClient) Source: https://connhex.com/docs/api/iam/policies/policies-get-tenant This C# code example shows how to use the HttpClient class to fetch tenant details. It includes setting the request method, URL, and headers, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./iam/tenants/:id"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### HTTP GET Request Example using HttpClient (C#) Source: https://connhex.com/docs/api/auth/get-verification-flow This C# code snippet demonstrates how to make an HTTP GET request to the Connhex authentication endpoint using HttpClient. It sets the necessary headers and handles the response, ensuring success and reading the content as a string. This is useful for interacting with the API from a .NET application. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://accounts./auth/self-service/verification/flows"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Perform Registration Request with HttpClient Source: https://connhex.com/docs/api/auth/create-browser-registration-flow Example implementation of a GET request to the self-service registration endpoint using C# HttpClient. It sets the required Accept header and reads the response content. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://accounts./auth/self-service/registration/browser"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### HTTP GET Request with Bearer Token Authentication (C#) Source: https://connhex.com/docs/api/resources/read-type-two-resource Example of making an HTTP GET request to retrieve resources, including setting the 'Accept' header to 'application/vnd.api+json' and providing a Bearer token for authentication. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./resources/resources/typeTwoResources/:ids/"); request.Headers.Add("Accept", "application/vnd.api+json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Making Authenticated GET Request with C# HttpClient Source: https://connhex.com/docs/api/resources/list-associated-type-two-resources Example of how to make an authenticated GET request to the Connhex API using C#'s HttpClient. It demonstrates setting headers for Accept and Authorization, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./resources/resources/typeOneResources/:ids/typeTwoResources/"); request.Headers.Add("Accept", "application/vnd.api+json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### GET /configurations Source: https://connhex.com/docs/remote-init/configuration-download Retrieves the initialization configuration for a specific device using an authentication key. ```APIDOC ## GET /configurations ### Description Downloads the device initialization configuration. This is typically used during the initialization phase, after a reboot, or for periodic configuration synchronization. ### Method GET ### Endpoint /configurations ### Parameters #### Query Parameters - **device_id** (string) - Required - The unique identifier for the device (e.g., serial number or MAC address). - **auth_key** (string) - Required - The authentication key used to authorize the request (Initialization, Migration, or Provisioning key). ### Request Example GET /configurations?device_id=SN123456&auth_key=init_key_abc123 ### Response #### Success Response (200) - **config** (object) - The device configuration parameters. #### Response Example { "status": "success", "config": { "server_url": "https://api.connhex.com", "polling_interval": 300 } } ``` -------------------------------- ### Server-Side Integration Example Source: https://connhex.com/docs/api/auth/get-recovery-flow This pseudo-code example demonstrates how to integrate the recovery flow retrieval into a server-side application using a client SDK. It shows how to pass the incoming Cookie header and query parameters to the SDK method. ```pseudo-code router.get('/recovery', async function (req, res) { const flow = await client.getRecoveryFlow(req.header('Cookie'), req.query['flow']) res.render('recovery', flow) }) ``` -------------------------------- ### Create Device Request (C# HttpClient) Source: https://connhex.com/docs/api/manufacturing/create-devices Example of creating a new device using C# HttpClient. It demonstrates setting up the HTTP request, including headers and the JSON payload, and sending it to the Connhex API. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://apis./manufacturing/manufacturing/devices/"); request.Headers.Add("Accept", "application/vnd.api+json"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"data\": {\n \"type\": \"string\",\n \"id\": \"string\",\n \"links\": {\n \"self\": \"string\"\n },\n \"attributes\": {\n \"pcbPartNumber\": \"string\",\n \"deviceType\": \"string\",\n \"fwVersion\": \"string\",\n \"partNumber\": \"string\",\n \"serialNumber\": \"string\",\n \"packageId\": \"string\",\n \"palletId\": \"string\",\n \"productionOrder\": \"string\",\n \"workOrder\": \"string\",\n \"connhexId\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n \"createdAt\": \"2024-07-29\",\n \"updatedAt\": \"2024-07-29\",\n \"deletedAt\": \"2024-07-29\"\n }\n }\n}", null, "application/vnd.api+json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Dart Example for Generic Error Source: https://connhex.com/docs/api/auth/update-recovery-flow Provides an example of handling a generic JSON API error response in Dart using the http package. It demonstrates making a GET request and processing the JSON response, including error handling. ```dart import 'package:http/http.dart' as http; import 'dart:convert'; Future fetchData() async { final response = await http.get(Uri.parse('https://api.example.com/resource')); if (response.statusCode == 200) { // Process successful response } else { final errorData = jsonDecode(response.body); // Handle errorData } } ``` -------------------------------- ### GET /auth/self-service/recovery/flows Source: https://connhex.com/docs/api/auth/get-recovery-flow Initiates a self-service account recovery flow. This endpoint is used to start the process of recovering access to an account. ```APIDOC ## GET /auth/self-service/recovery/flows ### Description Initiates a self-service account recovery flow for a user. ### Method GET ### Endpoint https://accounts./auth/self-service/recovery/flows ### Parameters #### Query Parameters - **id** (string) - Required - The recovery flow ID. ### Request Example GET https://accounts./auth/self-service/recovery/flows?id=example-id ### Response #### Success Response (200) - **flow** (object) - The recovery flow details. #### Response Example { "id": "example-id", "state": "active" } ``` -------------------------------- ### Perform HTTP GET Request with C# HttpClient Source: https://connhex.com/docs/api/auth/create-native-verification-flow Demonstrates how to initialize an HttpClient and perform a GET request to the Connhex verification API. It includes setting the Accept header and reading the response content. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://accounts./auth/self-service/verification/api"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Activate Firmware Release using C# HttpClient Source: https://connhex.com/docs/api/core/firmwares/activates-release This snippet demonstrates how to perform a POST request to the activation endpoint using the C# HttpClient class. It includes setting the Authorization header with a Bearer token and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://apis./iot/firmwares/:firmwareId/releases/:releaseId/activate"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### JSON:API Device Resource Response Source: https://connhex.com/docs/resources/json-api An example of a GET request response for device resources following the JSON:API specification. It demonstrates the structure of attributes, relationships, and metadata fields. ```json { "jsonapi": { "version": "1.0" }, "meta": { "count": 2 }, "links": { "self": "api/resources/devices/5b5ebc9b-6fbc-40ca-83b2-020b8969bf65,7889beca-a845-40e4-a9c5-1fca3957eff2" }, "data": [ { "type": "devices", "id": "5b5ebc9b-6fbc-40ca-83b2-020b8969bf65", "attributes": { "serial": "VV-KOK5DLPS06T1H3", "type": "valve", "connhex-id": "b6f9bb6d-6ffb-4a5c-8539-d79aa292a640", "metadata": "", "created-at": "2022-01-25T08:25:08.633Z", "updated-at": null, "deleted-at": null }, "relationships": { "tags": { "links": { "self": "api/resources/devices/5b5ebc9b-6fbc-40ca-83b2-020b8969bf65/relationships/tags", "related": "api/resources/devices/5b5ebc9b-6fbc-40ca-83b2-020b8969bf65/tags" }, "data": [ { "type": "tags", "id": "59065461-a379-46ed-86ae-295f7f7d6198" } ] }, "plant": { "links": { "self": "api/resources/devices/5b5ebc9b-6fbc-40ca-83b2-020b8969bf65/relationships/plant", "related": "api/resources/devices/5b5ebc9b-6fbc-40ca-83b2-020b8969bf65/plant" }, "data": null } }, "links": { "self": "api/resources/devices/5b5ebc9b-6fbc-40ca-83b2-020b8969bf65" } } ] } ``` -------------------------------- ### Retrieve Customer Information (C#) Source: https://connhex.com/docs/api/pay/retrieve Provides a C# example using HttpClient to fetch customer data from the Connhex API. It shows how to set up the request, send it, and handle the response, ensuring success and reading the content. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./pay/customers/:id"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Login Flow API Request (C#) Source: https://connhex.com/docs/api/auth/get-login-flow Example of how to make a GET request to the login flow endpoint using HttpClient in C#. It includes setting the Accept header and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://accounts./auth/self-service/login/flows"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### POST /iot/firmwares - Create Firmware Source: https://connhex.com/docs/api/core/firmwares/creates-new-firmware Creates a new firmware model configuration. Requires 'core:firmwares:create' authorization. ```APIDOC ## POST /iot/firmwares ### Description Creates a new firmware model configuration. ### Method POST ### Endpoint https://apis./iot/firmwares ### Parameters #### Request Body - **model_id** (string) - Required - The ID of the firmware model. - **name** (string) - Required - The name of the firmware. Must be <= 1024 characters. - **architecture** (string) - Required - The architecture of the firmware. - **description** (string) - Optional - A description for the firmware. - **metadata** (object) - Optional - Additional metadata for the firmware. - **tags** (string[]) - Optional - Tags associated with the firmware. ### Request Example ```json { "model_id": "string", "name": "string", "architecture": "string", "description": "string", "metadata": {}, "tags": [ "string" ] } ``` ### Response #### Success Response (201) - **Location** (string) - URL to the newly created firmware resource. #### Response Example (No specific JSON example provided for success response, but a Location header is returned) #### Error Responses - **400**: Failed due to malformed JSON. - **401**: Missing or invalid access token provided. - **403**: User not authorized to create firmware. - **409**: Firmware with provided ID already exists. - **415**: Missing or invalid content type. - **500**: Unexpected server-side error occurred. ``` -------------------------------- ### Manage systemd service lifecycle Source: https://connhex.com/docs/quickstart/start-edge-service Commands to start the service manually and enable it to run automatically on system boot. ```bash systemctl start connhex-edge-diagnostic systemctl enable connhex-edge-diagnostic ``` -------------------------------- ### Fetch Type Two Resources by IDs Source: https://connhex.com/docs/api/resources/read-associated-type-one-resource Provides code examples for fetching 'typeTwoResources' using their IDs. This involves making a GET request to the specified endpoint with appropriate headers for content type and authorization. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./resources/resources/typeTwoResources/:ids/typeOneResource/"); request.Headers.Add("Accept", "application/vnd.api+json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Create Tenant via HTTP POST Source: https://connhex.com/docs/api/iam/policies/policies-create-tenant Demonstrates how to create a new tenant by sending a JSON payload to the /iam/tenants endpoint. The request requires a unique ID and a name, with an optional flag to skip default policy creation. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://apis./iam/tenants"); request.Headers.Add("Accept", "application/json"); var content = new StringContent("{\n \"name\": \"My Custom Tenant\",\n \"id\": \"custom-tenant\",\n \"skip_policies\": true\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` ```json { "name": "My Custom Tenant", "id": "custom-tenant", "skip_policies": true } ``` -------------------------------- ### Create Firmware Release - C# HttpClient Source: https://connhex.com/docs/api/core/firmwares/creates-new-release This C# code snippet demonstrates how to create a new firmware release using HttpClient. It sends a POST request to the firmware release endpoint with necessary headers and content type. Ensure you replace `` with a valid authorization token and `` with your Connhex domain. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://apis./iot/firmwares/:firmwareId/releases"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent(string.Empty); content.Headers.ContentType = new MediaTypeHeaderValue("multipart/form-data"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Retrieve Rule Details via HttpClient Source: https://connhex.com/docs/api/rules-engine/read Example of how to fetch a specific rule's configuration from the Connhex API using the C# HttpClient library. It performs a GET request and outputs the JSON response body. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://apis./rules/:id"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Go Example for Generic Error Source: https://connhex.com/docs/api/auth/update-recovery-flow Illustrates how to handle a generic JSON API error response in Go. This snippet shows making an HTTP GET request and parsing the JSON response, including error checking. ```go package main import ( "encoding/json" "fmt" "net/http" ) func main() { resp, err := http.Get("https://api.example.com/resource") if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { var errorResponse map[string]interface{} json.NewDecoder(resp.Body).Decode(&errorResponse) fmt.Println("API Error:", errorResponse["error"]) } else { // Process successful response } } ``` -------------------------------- ### Initiate Login Flow - API Request Source: https://connhex.com/docs/auth/authentication-flows This snippet shows how to make a GET request to initiate the authentication process for a user in a native application. It requires specifying the domain and is the first step to obtain a session token. The response contains essential information like the flow ID and action URL. ```bash $ curl -XGET https://accounts..dev/auth/self-service/login/api ``` -------------------------------- ### Fetch Connhex API Errors using C# HttpClient Source: https://connhex.com/docs/api/auth/get-flow-error Example of how to fetch API errors from the Connhex authentication endpoint using C#'s HttpClient. This code sends a GET request and handles the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://accounts./auth/self-service/errors"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Download Firmware Binary (GET Request) Source: https://connhex.com/docs/ota-firmware-update/firmware-update-flow This snippet illustrates how to download the firmware binary using an HTTP GET request. It supports downloading the entire binary or partial downloads using the 'Range' header for efficient handling of large files and resuming interrupted downloads. Authentication is required. ```http GET /iot/edge/ota/ HTTP/1.1 Host: .connhex.com Authorization: Thing Range: bytes=- ``` -------------------------------- ### Verify File Existence and Permissions (Bash) Source: https://connhex.com/docs/edge/customizing-env-path Lists details of a specified environment file, including permissions, to ensure it is accessible by the service. ```bash ls -la /path/to/your/agent.env ``` -------------------------------- ### List All Tenants API Endpoint Source: https://connhex.com/docs/api/iam/policies/policies-list-tenants This section describes the GET request to list all tenants. It specifies the endpoint URL and the required authorization action. The response includes a schema and example for both successful (200) and default error responses. ```http GET ## https://apis./iam/tenants ``` -------------------------------- ### Initiate User Registration API Request Source: https://connhex.com/docs/auth/authentication-flows This code snippet demonstrates how to make a GET request to the Connhex registration API to initiate a new user registration flow. The API returns a flow ID and details required to complete the registration process. ```bash $ curl -XGET https://accounts./auth/self-service/registration/api ``` -------------------------------- ### Rust Example for Generic Error Source: https://connhex.com/docs/api/auth/update-recovery-flow Shows how to handle a generic JSON API error response in Rust using the 'reqwest' crate. This snippet demonstrates making an HTTP GET request and parsing the JSON response, including error handling. ```rust use reqwest::Error; #[tokio::main] async fn main() -> Result<(), Error> { let url = "https://api.example.com/resource"; let response = reqwest::get(url).await?; if response.status().is_success() { let data: serde_json::Value = response.json().await?; // Process successful response } else { let error_data: serde_json::Value = response.json().await?; eprintln!("API Error: {:?}", error_data); // Handle error } Ok(()) } ``` -------------------------------- ### Python Example for Generic Error Source: https://connhex.com/docs/api/auth/update-recovery-flow Illustrates handling a generic JSON API error response in Python using the 'requests' library. This snippet shows making an HTTP GET request and parsing the JSON response, including error handling. ```python import requests url = 'https://api.example.com/resource' try: response = requests.get(url) response.raise_for_status() # Raise an exception for bad status codes data = response.json() # Process successful response except requests.exceptions.HTTPError as errh: print(f"Http Error: {errh}") error_data = response.json() # Handle error_data except requests.exceptions.ConnectionError as errc: print(f"Error Connecting: {errc}") except requests.exceptions.Timeout as errt: print(f"Timeout Error: {errt}") except requests.exceptions.RequestException as err: print(f"Oops: Something Else: {err}") ``` -------------------------------- ### Create New Firmware - C# HttpClient Source: https://connhex.com/docs/api/core/firmwares/creates-new-firmware This C# code snippet demonstrates how to create a new firmware configuration using HttpClient. It sends a POST request to the firmware endpoint with the required JSON payload and includes authorization headers. Ensure you have the correct domain and bearer token. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://apis./iot/firmwares"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"model_id\": \"string\",\n \"name\": \"string\",\n \"architecture\": \"string\",\n \"description\": \"string\",\n \"metadata\": {\},\n \"tags\": [\n \"string\"\n ]\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### GET /iot/edge/ota/ Source: https://connhex.com/docs/ota-firmware-update/firmware-update-flow Download the firmware binary. Supports full downloads or partial downloads using the Range header. ```APIDOC ## GET /iot/edge/ota/ ### Description Downloads the firmware binary for the device. Supports the HTTP Range header for partial downloads and resuming interrupted transfers. ### Method GET ### Endpoint /iot/edge/ota/ ### Parameters #### Path Parameters - **init_id** (string) - Required - The unique identifier of the device. #### Headers - **Authorization** (string) - Required - Format: "Thing " - **Range** (string) - Optional - Byte range for partial downloads (e.g., "bytes=0-1023"). ### Response #### Success Response (200) - **Body** - The binary firmware file content. #### Success Response (206) - **Body** - Partial binary content for range requests. ``` -------------------------------- ### C# HTTP Request Example for Connhex API Source: https://connhex.com/docs/api/iam/identities/get-identity This C# code snippet demonstrates how to make a GET request to the Connhex API using HttpClient. It includes setting the request URL, adding an 'Accept' header for JSON, sending the request, ensuring a successful status code, and reading the response content. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://connhex.com/iam/identities/:id"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ```