### Create Order Question using C# HttpClient Source: https://apirest.3dcart.com/v2/orders/index This C# example uses `HttpClient` to create an order question. Ensure you have installed the `Microsoft.Net.Http` NuGet package. This code sends a POST request with the necessary authentication headers and a JSON body. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using (var content = new StringContent("{ \"QuestionAnswerIndexID\": 90228360, \"OrderID\": -21765798, \"QuestionID\": -66276798, \"QuestionTitle\": \"dolore sed irure exercitation ut\", \"QuestionAnswer\": \"ipsum laborum aute\", \"QuestionType\": \"reprehen\", \"QuestionCheckoutStep\": -51846949, \"QuestionSorting\": 37136667, \"QuestionDiscountGroup\": -18833721}", System.Text.Encoding.Default, "application/json")) { using (var response = await httpClient.PostAsync("3dCartWebAPI/v1/Orders/{orderid}/Questions", content)) { string responseData = await response.Content.ReadAsStringAsync(); } } } ``` -------------------------------- ### Retrieve Customer Group by ID using C# Source: https://apirest.3dcart.com/v2/customer-groups/index This C# code example shows how to retrieve a customer group by ID using HttpClient. It includes setting the base address, default headers for authentication and content type, and making a GET request. Ensure the Microsoft.Net.Http NuGet package is installed. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/CustomerGroups/{id}")) { string responseData = await response.Content.ReadAsStringAsync(); } } ``` -------------------------------- ### Retrieve Promotion by ID using C# Source: https://apirest.3dcart.com/v2/promotions/index Retrieves a specific promotion by ID using HttpClient in C#. Ensure the Microsoft.Net.Http NuGet package is installed. This example demonstrates setting base address and authentication headers, then making a GET request. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/Promotions/{id}")) { string responseData = await response.Content.ReadAsStringAsync(); } } ``` -------------------------------- ### Retrieve Transactions List (C#) Source: https://apirest.3dcart.com/v2/orders/index Retrieves transaction data for an order using HttpClient in C#. This example requires the Microsoft.Net.Http NuGet package. It sets up the base address and adds necessary authentication headers before making a GET request. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/Orders/{orderid}/Transactions")) { string responseData = await response.Content.ReadAsStringAsync(); } } ``` -------------------------------- ### Get RMA Items List - C# Source: https://apirest.3dcart.com/v2/rma/index Fetches RMA items using HttpClient in C#. Ensure the Microsoft.Net.Http NuGet package is installed. This method sends a GET request with authentication headers and returns the response content as a string. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/RMA/{rmaid}/Items")) { string responseData = await response.Content.ReadAsStringAsync(); } } ``` -------------------------------- ### C# HTTP Client Example Source: https://apirest.3dcart.com/v2/orders/index Example of how to make a request to the 3dcart API using C#'s HttpClient, including setting base address and default headers. ```APIDOC ## C# HTTP Client Example ### Description This example shows how to use C#'s `HttpClient` to interact with the 3dcart API. It demonstrates setting the base address, default request headers for authentication and content negotiation. ### Method GET/POST (depending on the specific endpoint) ### Endpoint /websites/apirest_3dcart ### Parameters #### Headers * **accept**: application/json * **secureurl**: [Your Secure URL] * **privatekey**: [Your Private Key] * **token**: [Your Token] ### Request Example ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { // Set default headers for all requests httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); // Replace with your SecureURL httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); // Replace with your PrivateKey httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); // Replace with your Token // Example of making a GET request (replace with actual endpoint if needed) // var response = await httpClient.GetAsync("your/endpoint"); // Example of making a POST request (replace with actual endpoint and data) // var requestData = new { /* your data object */ }; // var jsonContent = System.Text.Json.JsonSerializer.Serialize(requestData); // var httpContent = new StringContent(jsonContent, System.Text.Encoding.UTF8, "application/json"); // var response = await httpClient.PostAsync("your/endpoint", httpContent); // response.EnsureSuccessStatusCode(); // Throws an exception if the response status code is not a success code // var responseBody = await response.Content.ReadAsStringAsync(); // Console.WriteLine(responseBody); } ``` ### Response #### Success Response (200) * **(Response structure depends on the specific API endpoint called)** #### Response Example ```json // Response content will vary based on the endpoint and request. // Example for a hypothetical successful response: { "message": "Operation successful" } ``` ``` -------------------------------- ### Retrieve Customer by ID using C# Source: https://apirest.3dcart.com/v2/customers/index This C# code example shows how to fetch customer data by ID using HttpClient. Ensure you have the Microsoft.Net.Http NuGet package installed. The code sets necessary headers and makes a GET request to the API endpoint. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/Customers/{id}")) { string responseData = await response.Content.ReadAsStringAsync(); } } ``` -------------------------------- ### Retrieve Payment Tokens - C# Source: https://apirest.3dcart.com/v2/payment-tokens/index This C# example demonstrates retrieving payment tokens using `HttpClient`. It sets the base address for the API and adds necessary headers for authentication and content type. The response content is read as a string asynchronously. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/PaymentTokens")) { string responseData = await response.Content.ReadAsStringAsync(); } } ``` -------------------------------- ### Create Order Transaction using C# HttpClient Source: https://apirest.3dcart.com/v2/orders/index This C# example shows how to create a transaction using the HttpClient class. It requires the 'Microsoft.Net.Http' NuGet package and includes headers for authentication and content type. Note the commented-out line for disabling certificate validation, intended only for non-production environments. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using (var content = new StringContent("{ \"TransactionIndexID\": 62402389, \"OrderID\": -60245923, \"TransactionID\": \"id Excepteur et\", \"TransactionDateTime\": \"1985-06-16T01:47:51.107Z\", \"TransactionType\": \"q\", \"TransactionMethod\": \"eiusmod culpa\", \"TransactionAmount\": 96737334.38516226, \"TransactionApproval\": \"in\", \"TransactionReference\": \"ullamco adipisicing irure commodo\", \"TransactionGatewayID\": 76363722, \"TransactionCVV2\": \"deserunt sunt dolor\", \"TransactionAVS\": \"tempor irure nulla\", \"TransactionResponseText\": \"tempor non m\", \"TransactionResponseCode\": \"sed\", \"TransactionCaptured\": 2317668}", System.Text.Encoding.Default, "application/json")) { using (var response = await httpClient.PostAsync("3dCartWebAPI/v1/Orders/{orderid}/Transactions", content)) { string responseData = await response.Content.ReadAsStringAsync(); } } } ``` -------------------------------- ### GET /Products/{id} Source: https://apirest.3dcart.com/v2/examples/index Retrieve a specific product by its Catalog ID. This endpoint is used to fetch detailed information about a product, including its SKU, pricing, and available options. ```APIDOC ## GET /Products/{id} ### Description Retrieve a specific product by its Catalog ID. This endpoint is used to fetch detailed information about a product, including its SKU, pricing, and available options. ### Method GET ### Endpoint `https://apirest.3dcart.com/3dCartWebAPI/v2/Products/{id}` ### Parameters #### Path Parameters - **id** (integer) - Required - The Catalog ID of the product to retrieve. ### Response #### Success Response (200) - **SKUInfo** (object) - Information about the product's SKU. - **CatalogID** (integer) - The unique identifier for the product. - **SKU** (string) - The Stock Keeping Unit of the product. - **Name** (string) - The name of the product. - **Cost** (number) - The cost of the product. - **Price** (number) - The selling price of the product. - **Currency** (string) - The currency of the price. - **RetailPrice** (number) - The retail price of the product. - **SalePrice** (number) - The sale price of the product. - **OnSale** (boolean) - Indicates if the product is on sale. - **Stock** (number) - The current stock level of the product. - **OptionSetList** (array) - A list of option sets available for the product. - **OptionSetID** (integer) - The unique identifier for the option set. - **OptionSetName** (string) - The name of the option set (e.g., Color, Size). - **OptionSorting** (number) - The sorting order for the option set. - **OptionRequired** (boolean) - Indicates if the option is required. - **OptionType** (string) - The type of option (e.g., Dropdown). - **OptionURL** (string) - URL associated with the option. - **OptionAdditionalInformation** (string) - Additional information about the option. - **OptionSizeLimit** (integer) - The size limit for the option. - **OptionList** (array) - A list of individual options within the option set. - **OptionID** (integer) - The unique identifier for the option. - **OptionName** (string) - The name of the option (e.g., Red, Small). - **OptionSelected** (boolean) - Indicates if the option is selected by default. - **OptionHide** (boolean) - Indicates if the option should be hidden. - **OptionValue** (number) - The value associated with the option. - **OptionPartNumber** (string) - The part number for the option. - **OptionSorting** (number) - The sorting order for the option. - **OptionImagePath** (string) - Path to the image for the option. - **OptionBundleCatalogId** (integer) - Catalog ID for bundled options. - **OptionBundleQuantity** (integer) - Quantity for bundled options. #### Response Example ```json [ { "SKUInfo":{ "CatalogID":61850, "SKU":"APITEST01", "Name":"Testing the API", "Cost":1.0, "Price":2.0, "Currency":"", "RetailPrice":2.5, "SalePrice":0.0, "OnSale":false, "Stock":100.0 }, "OptionSetList":[ { "OptionSetID":21, "OptionSetName":"Color", "OptionSorting":1.0, "OptionRequired":false, "OptionType":"Dropdown", "OptionURL":"", "OptionAdditionalInformation":"", "OptionSizeLimit":0, "OptionList":[ { "OptionID":67, "OptionName":"Red", "OptionSelected":false, "OptionHide":false, "OptionValue":0.0, "OptionPartNumber":"", "OptionSorting":1.0, "OptionImagePath":"", "OptionBundleCatalogId":0, "OptionBundleQuantity":0 }, { "OptionID":68, "OptionName":"Black", "OptionSelected":false, "OptionHide":false, "OptionValue":0.0, "OptionPartNumber":"", "OptionSorting":2.0, "OptionImagePath":"", "OptionBundleCatalogId":0, "OptionBundleQuantity":0 } ] }, { "OptionSetID":22, "OptionSetName":"Size", "OptionSorting":2.0, "OptionRequired":false, "OptionType":"Dropdown", "OptionURL":"", "OptionAdditionalInformation":"", "OptionSizeLimit":0, "OptionList":[ { "OptionID":69, "OptionName":"Small", "OptionSelected":false, "OptionHide":false, "OptionValue":0.0, "OptionPartNumber":"", "OptionSorting":1.0, "OptionImagePath":"", "OptionBundleCatalogId":0, "OptionBundleQuantity":0 }, { "OptionID":70, "OptionName":"Medium", "OptionSelected":false, "OptionHide":false, "OptionValue":0.0, "OptionPartNumber":"", "OptionSorting":2.0, "OptionImagePath":"", "OptionBundleCatalogId":0, "OptionBundleQuantity":0 } ] } ] } ] ``` ``` -------------------------------- ### Create Order Question using Ruby RestClient Source: https://apirest.3dcart.com/v2/orders/index This Ruby example utilizes the `rest_client` gem to create an order question. It defines the request payload and headers, including authentication credentials, and sends a POST request to the API endpoint. ```ruby require 'rubygems' if RUBY_VERSION < '1.9' require 'rest_client' values = '{ "QuestionAnswerIndexID": 90228360, "OrderID": -21765798, "QuestionID": -66276798, "QuestionTitle": "dolore sed irure exercitation ut", "QuestionAnswer": "ipsum laborum aute", "QuestionType": "reprehen", "QuestionCheckoutStep": -51846949, "QuestionSorting": 37136667, "QuestionDiscountGroup": -18833721 }' headers = { :content_type => 'application/json', :accept => 'application/json', :secureurl => '', :privatekey => '', :token => '' } response = RestClient.post 'https://apirest.3dcart.com/3dCartWebAPI/v2/Orders/{orderid}/Questions', values, headers puts response ``` -------------------------------- ### Create a Cart using C# Source: https://apirest.3dcart.com/v2/carts/index This C# code snippet illustrates how to create a new cart using the HttpClient class. It requires authentication headers and a JSON payload. Note the comment regarding `ServerCertificateValidationCallback` for sandbox environments, which should only be used for non-production purposes. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using (var content = new StringContent("{ \"CustomerId\": -80365023, \"BillingFirstName\": \"culpa ut\", \"BillingLastName\": \"esse tempor ut\", \"BillingCompany\": \"id\", \"BillingAddress\": \"laborum veniam in\", \"BillingAddress2\": \"ipsum e\", \"BillingCity\": \"labore do sint\", \"BillingState\": \"ni\", \"BillingZipCode\": \"dolo\", \"BillingCountry\": \"qui culpa\", \"BillingPhoneNumber\": \"eu\", \"BillingEmail\": \"laboris veniam sed aliquip Ut\", \"ShipmentFirstName\": \"dolore Excepteur\", \"ShipmentLastName\": \"aliquip ipsum cillum culpa tempor\", \"ShipmentCompany\": \"in velit magna est\", \"ShipmentAddress\": \"proident sunt adipisicing minim id\", \"ShipmentAddress2\": \"cupidatat commodo\", \"ShipmentCity\": \"incididunt \", \"ShipmentState\": \"consequat d\", \"ShipmentZipCode\": \"Ut voluptate et pr\", \"ShipmentCountry\": \"aute \", \"ShipmentPhone\": \"aliquip exercitation qui deserunt\", \"ShipmentEmail\": \"fugiat sint\"}", System.Text.Encoding.Default, "application/json")) { using (var response = await httpClient.PostAsync("3dCartWebAPI/v1/Cart", content)) { string responseData = await response.Content.ReadAsStringAsync(); } } } ``` -------------------------------- ### Retrieve Gift Registry by ID using Python Source: https://apirest.3dcart.com/v2/gift-registries/index This Python example uses `urllib2` to send a GET request to the 3dCart API to fetch a Gift Registry. It defines the required headers for authentication and specifies the API endpoint. ```python from urllib2 import Request, urlopen headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'SecureURL': '', 'PrivateKey': '', 'Token': '' } request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/GiftRegistries/{giftregistryid}', headers=headers) response_body = urlopen(request).read() print response_body ``` -------------------------------- ### Retrieve Category by ID using Ruby Source: https://apirest.3dcart.com/v2/category/index Employs the 'rest_client' gem in Ruby to make a GET request for a specific category. Requires the 'rest_client' gem to be installed. Authentication headers are included in the request. ```ruby require 'rubygems' if RUBY_VERSION < '1.9' require 'rest_client' headers = { :content_type => 'application/json', :accept => 'application/json', :secureurl => '', :privatekey => '', :token => '' } response = RestClient.get 'https://apirest.3dcart.com/3dCartWebAPI/v2/Categories/{id}', headers puts response ``` -------------------------------- ### Create Payment Token using C# Source: https://apirest.3dcart.com/v2/payment-tokens/index This C# code snippet shows how to create a payment token using HttpClient. Ensure you have the 'Microsoft.Net.Http' NuGet package installed. It configures the request with necessary headers and sends a POST request with the payment token details. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using (var content = new StringContent("{ \"PaymentTokenID\": -58914564, \"CustomerID\": -40647657, \"OrderID\": 14857998, \"CustomerProfileID\": \"non magna\", \"PaymentProfileID\": \"in occaecat labore consequat\", \"CardLast4\": -56901638, \"CardExpMonth\": -58633376, \"CardExpYear\": 29669257, \"BillingPaymentMethodID\": 68433439, \"LastUpdate\": \"1987-09-27T20:30:15.838Z\", \"GatewayName\": \"labor\", \"GatewayID\": 2756726}", System.Text.Encoding.Default, "application/json")) { using (var response = await httpClient.PostAsync("3dCartWebAPI/v1/PaymentTokens", content)) { string responseData = await response.Content.ReadAsStringAsync(); } } } ``` -------------------------------- ### Create Manufacturer using C# HttpClient Source: https://apirest.3dcart.com/v2/manufacturers/index This C# snippet shows how to create a manufacturer using `HttpClient`. It configures the base address, sets necessary headers, and sends a POST request with the manufacturer data. Note the comment about disabling certificate validation for testing environments. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using (var content = new StringContent("{ \"ManufacturerID\": -16446886, \"ManufacturerName\": \"e\", \"Logo\": \"quis dese\", \"Sorting\": -20672828, \"Header\": \"laboris deserunt in minim mollit\", \"Website\": \"reprehenderit proident amet Duis\", \"UserID\": \"qui laborum su\", \"LastUpdate\": \"1982-05-02T09:20:10.518Z\", \"PageTitle\": \"magna cupidatat nisi do\", \"MetaTags\": \"aliquip consequat ea dolore\", \"RedirectURL\": \"consectetur adipisicing Lorem Excepteur\", \"FileName\": \"inci\"}", System.Text.Encoding.Default, "application/json")) { using (var response = await httpClient.PostAsync("3dCartWebAPI/v1/Manufacturers", content)) { string responseData = await response.Content.ReadAsStringAsync(); } } } ``` -------------------------------- ### Retrieve All Categories (Ruby) Source: https://apirest.3dcart.com/v2/category/index Uses the RestClient gem in Ruby to make a GET request to the 3dCart API for category data. Requires the 'rest_client' gem to be installed. Authentication headers are passed in a hash. ```ruby require 'rubygems' if RUBY_VERSION < '1.9' require 'rest_client' headers = { :content_type => 'application/json', :accept => 'application/json', :secureurl => '', :privatekey => '', :token => '' } response = RestClient.get 'https://apirest.3dcart.com/3dCartWebAPI/v2/Categories?limit=&offset=&category=&countonly=', headers puts response ``` -------------------------------- ### Update CRM Department - C# Source: https://apirest.3dcart.com/v2/crm/index Updates a specific CRM department using an HTTP PUT request in C#. This example utilizes the HttpClient class and requires authentication headers. Ensure the Microsoft.Net.Http NuGet package is installed. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using (var content = new StringContent("{ \"DepartmentId\": -99961439, \"Name\": \"adipisicing nulla qui magna enim\", \"Visible\": true}", System.Text.Encoding.Default, "application/json")) { using (var response = await httpClient.PutAsync("3dCartWebAPI/v1/CRM/department/{id}", content)) { string responseData = await response.Content.ReadAsStringAsync(); } } } ``` -------------------------------- ### Create Customer Group using C# Source: https://apirest.3dcart.com/v2/customer-groups/index This C# code example shows how to create a new customer group using HttpClient. It requires the `Microsoft.Net.Http` NuGet package. The code sends a POST request with a JSON payload to the 3dCart API, including necessary headers for authentication. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using (var content = new StringContent("{ \"CustomerGroupID\": -75462011, \"Name\": \"Excepteur reprehenderit mollit\", \"Description\": \"aliquip exer\", \"MinimumOrder\": 34158822.957761675, \"NonTaxable\": true, \"AllowRegistration\": false, \"DisableRewardPoints\": true, \"AutoApprove\": false, \"RegistrationMessage\": \"aute enim commodo eiusmod\", \"PriceLevel\": -48512740}", System.Text.Encoding.Default, "application/json")) { using (var response = await httpClient.PostAsync("3dCartWebAPI/v1/CustomerGroups", content)) { string responseData = await response.Content.ReadAsStringAsync(); } } } ``` -------------------------------- ### POST /Orders/{orderid}/Questions Source: https://apirest.3dcart.com/v2/orders/index Creates a new question associated with a specific order. Ensure you have your authentication credentials (Secure URL, Private Key, Token) set up. ```APIDOC ## POST /Orders/{orderid}/Questions ### Description Creates a new question for a given order. This endpoint allows you to add custom questions and answers to an order. ### Method POST ### Endpoint /Orders/{orderid}/Questions ### Parameters #### Path Parameters - **orderid** (string) - Required - The ID of the order to which the question will be added. #### Query Parameters None #### Request Body - **QuestionAnswerIndexID** (integer) - Required - The index ID for the question answer. - **OrderID** (integer) - Required - The ID of the order. - **QuestionID** (integer) - Required - The ID of the question. - **QuestionTitle** (string) - Required - The title of the question. - **QuestionAnswer** (string) - Required - The answer to the question. - **QuestionType** (string) - Required - The type of question. - **QuestionCheckoutStep** (integer) - Required - The checkout step where the question appears. - **QuestionSorting** (integer) - Required - The sorting order of the question. - **QuestionDiscountGroup** (integer) - Required - The discount group associated with the question. ### Request Example ```json { "QuestionAnswerIndexID": 90228360, "OrderID": -21765798, "QuestionID": -66276798, "QuestionTitle": "dolore sed irure exercitation ut", "QuestionAnswer": "ipsum laborum aute", "QuestionType": "reprehen", "QuestionCheckoutStep": -51846949, "QuestionSorting": 37136667, "QuestionDiscountGroup": -18833721 } ``` ### Response #### Success Response (200) - **Success** (boolean) - Indicates if the operation was successful. - **Message** (string) - A message describing the result of the operation. #### Response Example ```json { "Success": true, "Message": "Question created successfully." } ``` ``` -------------------------------- ### Making API Requests with C# HttpClient Source: https://apirest.3dcart.com/v2/orders/index This C# code example shows how to configure an HttpClient to interact with the 3dCart API. It sets the base address and adds default headers for Accept, SecureURL, PrivateKey, and Token. Note the commented-out line for disabling SSL certificate validation, which should only be used in non-production environments. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); // Add your request logic here, e.g., httpClient.PostAsJsonAsync(...) } ``` -------------------------------- ### Retrieve CRM Tickets List (Ruby) Source: https://apirest.3dcart.com/v2/crm/index Fetches CRM ticket data from the 3dCart API using the Ruby RestClient gem. This example demonstrates setting request headers for content type and authentication, then making a GET request. ```ruby require 'rubygems' if RUBY_VERSION < '1.9' require 'rest_client' headers = { :content_type => 'application/json', :accept => 'application/json', :secureurl => '', :privatekey => '', :token => '' } response = RestClient.get 'https://apirest.3dcart.com/3dCartWebAPI/v2/CRM?subject=&departmentid=&statusid=&openedstartdate=&openedenddate=&lastactionstartdate=&lastactionenddate=&customername=&customeremail=&customerphone=&customeripaddress=&orderid=&custid=&productid=&limit=&offset=&countonly=', headers puts response ``` -------------------------------- ### Retrieve Manufacturer by ID using C# Source: https://apirest.3dcart.com/v2/manufacturers/index This C# code example shows how to fetch manufacturer data using HttpClient. It requires the Microsoft.Net.Http NuGet package and involves setting the base address and authentication headers. Note: Certificate validation callback is for non-production use only. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/Manufacturers/{id}")) { string responseData = await response.Content.ReadAsStringAsync(); } } ``` -------------------------------- ### Update CRM Ticket - C# Source: https://apirest.3dcart.com/v2/crm/index Updates a specific CRM ticket using HttpClient in C#. Ensure the Microsoft.Net.Http NuGet package is installed. This example demonstrates sending a PUT request with JSON payload and handling the response asynchronously. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using (var content = new StringContent("{ \"DepartmentId\": -99961439, \"Name\": \"adipisicing nulla qui magna enim\", \"Visible\": true}", System.Text.Encoding.Default, "application/json")) { using (var response = await httpClient.PutAsync("3dCartWebAPI/v1/CRM/department/{id}", content)) { string responseData = await response.Content.ReadAsStringAsync(); } } } ``` -------------------------------- ### GET /3dCartWebAPI/v2/Orders/{orderid} Source: https://apirest.3dcart.com/v2/examples/index Retrieves a specific order by its ID. This endpoint is useful for obtaining detailed order information, including the OrderItemList which contains ItemIndexID for each item. This ItemIndexID is crucial for updating items in subsequent steps. ```APIDOC ## GET /3dCartWebAPI/v2/Orders/{orderid} ### Description Retrieves a specific order by its ID. This endpoint is useful for obtaining detailed order information, including the OrderItemList which contains ItemIndexID for each item. This ItemIndexID is crucial for updating items in subsequent steps. ### Method GET ### Endpoint https://apirest.3dcart.com/3dCartWebAPI/v2/Orders/{orderid} ### Parameters #### Path Parameters - **orderid** (string) - Required - The unique identifier of the order to retrieve. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **OrderItemList** (array) - A list of items included in the order, each with an **ItemIndexID**. #### Response Example ```json { "OrderItemList": [ { "ItemIndexID": "1", "ProductID": "PROD123", "Quantity": "1" } ] } ``` ``` -------------------------------- ### Retrieve Customer Groups - C# Source: https://apirest.3dcart.com/v2/customer-groups/index This C# snippet demonstrates retrieving customer groups using `HttpClient`. It sets up the base address and adds necessary headers for authentication and content type. The code asynchronously fetches the response and reads it as a string. Ensure you have the `Microsoft.Net.Http` NuGet package installed. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/CustomerGroups")) { string responseData = await response.Content.ReadAsStringAsync(); } } ``` -------------------------------- ### Retrieve Gift Registry by ID using C# Source: https://apirest.3dcart.com/v2/gift-registries/index This C# code example shows how to fetch a Gift Registry by its ID using HttpClient. It sets the necessary headers for authentication and content type. Note: The `ServerCertificateValidationCallback` line is for testing purposes only and should not be used in production. ```csharp //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses. //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line. using System; using System.Net.Http; var baseAddress = new Uri("https://apirest.3dcart.com/"); using (var httpClient = new HttpClient{ BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", ""); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", ""); using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/GiftRegistries/{giftregistryid}")) { string responseData = await response.Content.ReadAsStringAsync(); } } ``` -------------------------------- ### Create Customer with Python urllib2 Source: https://apirest.3dcart.com/v2/customers/index This Python example demonstrates customer creation using the urllib2 library. It constructs a JSON string for the customer data and defines a dictionary for the request headers, including authentication tokens, before sending the POST request. ```python from urllib2 import Request, urlopen values = """ { "CustomerID": 96318450, "Email": "laborum velit aliquip", "Password": "", "BillingCompany": "dolore amet cillum", "BillingFirstName": "officia veniam", "BillingLastName": "in nulla tempor", "BillingAddress1": "aliqua sunt adipisicing mollit", "BillingAddress2": "ullamco cill", "BillingCity": "reprehenderit laboris ullamco ", "BillingState": "aute tempor dolor", "BillingZipCode": "es", "BillingCountry": "cupidatat sint qui", "BillingPhoneNumber": "esse fugiat", "BillingTaxID": "proident", "ShippingCompany": "ea in sunt aute", "ShippingFirstName": "fugiat", "ShippingLastName": "ad venia", "ShippingAddress1": "esse sed", "ShippingAddress2": "commodo moll", "ShippingCity": "proident ipsum eiusmod cillum aute", "ShippingState": "commodo aliquip", "ShippingZipCode": "deseru", "ShippingCountry": "ut mollit minim", "ShippingPhoneNumber": "do n", "ShippingAddressType": -44788774, "CustomerGroupID": 50520008, "Enabled": true, "MailList": false, "NonTaxable": true, "DisableBillingSameAsShipping": true, "Comments": "eu", "AdditionalField1": "dolor sed adip", "AdditionalField2": "laboris elit Lorem minim", "AdditionalField3": "Duis ut enim eiusmod", "TotalStoreCredit": -15431326.976344898, "ResetPassword": true } """ headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'SecureURL': '', 'PrivateKey': '', 'Token': '' } request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/Customers', data=values, headers=headers) ```