### Get Production Resource (Python) Source: https://dearinventory.docs.apiary.io/reference/production/resource/get This Python example uses the 'requests' library to fetch production resource data. Make sure 'requests' is installed (`pip install requests`). ```python import requests url = "https://inventory.dearsystems.com/ExternalApi/v2/production/resource?ResourceID=ResourceID&IncludeAttachments=IncludeAttachments" headers = { "Content-Type": "application/json", "api-auth-accountid": "704ef231-cd93-49c9-a201-26b4b5d0d35b", "api-auth-applicationkey": "0342a546-e0c2-0dff-f0be-6a5e17154033" } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Java Example for Get Production Run Source: https://dearinventory.docs.apiary.io/reference/production/production-run/get Demonstrates how to fetch production run details using Java. This example shows a basic GET request structure. ```Java OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://inventory.dearsystems.com/ExternalApi/v2/production/order/run?ProductionOrderID=1c634596-eb51-4ff1-828b-ee1b42a9a5f1") .get() .addHeader("api-auth-accountid", "704ef231-cd93-49c9-a201-26b4b5d0d35b") .addHeader("api-auth-applicationkey", "0342a546-e0c2-0dff-f0be-6a5e17154033") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Get Production Order Reference Data (Go) Source: https://dearinventory.docs.apiary.io/reference/production/production-order/get-production-order-reference-data This Go example demonstrates how to fetch production order reference data. It includes setting up the HTTP GET request with necessary authentication headers. ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { url := "https://inventory.dearsystems.com/ExternalApi/v2/production/order/referenceData" client := &http.Client{} req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println(err) return } req.Header.Add("Content-Type", "application/json") req.Header.Add("api-auth-accountid", "704ef231-cd93-49c9-a201-26b4b5d0d35b") req.Header.Add("api-auth-applicationkey", "0342a546-e0c2-0dff-f0be-6a5e17154033") resp, err := client.Do(req) if err != nil { fmt.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Ruby Example for Get Production Run Source: https://dearinventory.docs.apiary.io/reference/production/production-run/get Example of how to call the Get Production Run API using Ruby. This snippet shows the necessary setup for an HTTP GET request. ```Ruby require 'uri' require 'net/http' url = URI("https://inventory.dearsystems.com/ExternalApi/v2/production/order/run?ProductionOrderID=1c634596-eb51-4ff1-828b-ee1b42a9a5f1") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["api-auth-accountid"] = "704ef231-cd93-49c9-a201-26b4b5d0d35b" request["api-auth-applicationkey"] = "0342a546-e0c2-0dff-f0be-6a5e17154033" response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Transactions - Groovy Example Source: https://dearinventory.docs.apiary.io/reference/transactions/transactions/get Groovy script to fetch transactions. This example uses the 'HTTPBuilder' library for making the GET request. ```Groovy import groovy.json.JsonOutput import groovy.json.JsonSlurper import groovy.util.slurpersupport.GPathResult HTTPBuilder http = new HTTPBuilder('https://inventory.dearsystems.com') http.setJsonGenerator(new JsonOutput()) http.setJsonParser(new JsonSlurper()) http.get(path: '/ExternalApi/v2/transactions', query: [ Page: '1', Limit: '100', FromDate: '2017-01-01', ToDate: '2017-12-31', Account: '610' ], headers: [ 'Content-Type': 'application/json', 'api-auth-accountid': '704ef231-cd93-49c9-a201-26b4b5d0d35b', 'api-auth-applicationkey': '0342a546-e0c2-0dff-f0be-6a5e17154033' ]) { response -> println "Status: ${response.status}" def slurper = new JsonSlurper() def result = slurper.parseText(response.data.text) println result } ``` -------------------------------- ### Perl Example for Get Production Run Source: https://dearinventory.docs.apiary.io/reference/production/production-run/get Example of how to call the Get Production Run API using Perl. This snippet uses the LWP::UserAgent module. ```Perl use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $response = $ua->get('https://inventory.dearsystems.com/ExternalApi/v2/production/order/run?ProductionOrderID=1c634596-eb51-4ff1-828b-ee1b42a9a5f1', 'api-auth-accountid' => '704ef231-cd93-49c9-a201-26b4b5d0d35b', 'api-auth-applicationkey' => '0342a546-e0c2-0dff-f0be-6a5e17154033'); if ($response->is_success) { print $response->decoded_content; } else { die $response->status_line; } ``` -------------------------------- ### Start Workflow Go Request Source: https://dearinventory.docs.apiary.io/reference/crm/start-a-workflow/post Example of starting a workflow using Go's net/http package. This snippet shows how to create a POST request with headers and a JSON body. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "https://inventory.dearsystems.com/ExternalApi/v2/crm/workflowstart?ID=ID&Name=Name&StartDate=StartDate&EnityType=EnityType&EntityID=EntityID" headers := map[string]string{ "Content-Type": "application/json", "api-auth-accountid": "704ef231-cd93-49c9-a201-26b4b5d0d35b", "api-auth-applicationkey": "0342a546-e0c2-0dff-f0be-6a5e17154033" } body := []byte("{}") req, err := http.NewRequest("POST", url, bytes.NewBuffer(body)) if err != nil { fmt.Println("Error creating request:", err) return } for key, value := range headers { req.Header.Set(key, value) } client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() var result map[string]interface{} if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { fmt.Println("Error decoding response:", err) return } fmt.Println(result) } ``` -------------------------------- ### Swift Example for Get Production Run Source: https://dearinventory.docs.apiary.io/reference/production/production-run/get Example of how to retrieve production run data using Swift. This snippet uses URLSession to perform the GET request. ```Swift import Foundation let url = URL(string: "https://inventory.dearsystems.com/ExternalApi/v2/production/order/run?ProductionOrderID=1c634596-eb51-4ff1-828b-ee1b42a9a5f1") var request = URLRequest(url: url!) request.httpMethod = "GET" request.setValue("704ef231-cd93-49c9-a201-26b4b5d0d35b", forHTTPHeaderField: "api-auth-accountid") request.setValue("0342a546-e0c2-0dff-f0be-6a5e17154033", forHTTPHeaderField: "api-auth-applicationkey") let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } guard let data = data else { return } let responseString = String(data: data, encoding: .utf8) print(responseString ?? "") } task.resume() ``` -------------------------------- ### Go Example for Production Order List Source: https://dearinventory.docs.apiary.io/reference/production/production-order-list/get Example of how to call the Production Order List GET API using Go's 'net/http' package. This snippet shows how to set up the request with headers and query parameters. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://inventory.dearsystems.com/ExternalApi/v2/production/orderList?Page=1&Limit=10&Status=Completed" client := &http.Client{} req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Add("Content-Type", "application/json") req.Header.Add("api-auth-accountid", "704ef231-cd93-49c9-a201-26b4b5d0d35b") req.Header.Add("api-auth-applicationkey", "0342a546-e0c2-0dff-f0be-6a5e17154033") resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println(string(body)) } ``` -------------------------------- ### PHP Example: Connecting to Cin7 Core API Source: https://dearinventory.docs.apiary.io/introduction/connecting-to-the-api This PHP snippet demonstrates how to make a GET request to the Cin7 Core API, including the necessary Account ID and Application Key in the HTTP headers. Ensure you replace 'youraccountid' and 'applicationkey' with your actual credentials. ```php $account_id = 'api-auth-accountid: youraccountid'; $application_key = 'api-auth-applicationkey: applicationkey'; $naked_dear_url = 'https://inventory.dearsystems.com/ExternalApi/v2/SaleList'; $data = array ('Page' => '1', 'Limit' => '100'); $data = http_build_query($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$naked_dear_url."?". ``` ```php $data); //GET API CALL curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $headers = [ "Content-type: application/json", $account_id, $application_key ]; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $server_output = curl_exec ($ch); curl_close ($ch); print $server_output ; ``` -------------------------------- ### Objective-C Example for Get Production Run Source: https://dearinventory.docs.apiary.io/reference/production/production-run/get Example of how to retrieve production run data using Objective-C. This snippet uses NSURLSession to perform the GET request. ```Objective-C #import int main(int argc, const char * argv[]) { @autoreleasepool { NSURL *url = [NSURL URLWithString:@"https://inventory.dearsystems.com/ExternalApi/v2/production/order/run?ProductionOrderID=1c634596-eb51-4ff1-828b-ee1b42a9a5f1"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"GET"]; [request setValue:@"704ef231-cd93-49c9-a201-26b4b5d0d35b" forHTTPHeaderField:@"api-auth-accountid"]; [request setValue:@"0342a546-e0c2-0dff-f0be-6a5e17154033" forHTTPHeaderField:@"api-auth-applicationkey"]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"%@", error); } else { NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"%@", responseString); } }]; [dataTask resume]; } return 0; } ``` -------------------------------- ### Brand GET Request Example (Go) Source: https://dearinventory.docs.apiary.io/reference/brand/brand/get Example of how to make a GET request to retrieve brand data using Go. Includes sample headers for authentication. ```Go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { client := &http.Client{} req, err := http.NewRequest("GET", "https://inventory.dearsystems.com/ExternalApi/v2/ref/brand?Page=1&Limit=100", nil) if err != nil { panic(err) } req.Header.Add("Api-Auth-Accountid", "704ef231-cd93-49c9-a201-26b4b5d0d35b") req.Header.Add("Api-Auth-Applicationkey", "0342a546-e0c2-0dff-f0be-6a5e17154033") res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { panic(err) } fmt.Println(string(body)) } ``` -------------------------------- ### Groovy Example for Get Production Run Source: https://dearinventory.docs.apiary.io/reference/production/production-run/get Example of how to call the Get Production Run API using Groovy. This snippet demonstrates using the HTTPBuilder library. ```Groovy import groovy.json.JsonSlurper import groovy.json.JsonOutput import groovy.util.slurpersupport.GPathResult HTTPBuilder client = new HTTPBuilder('https://inventory.dearsystems.com') client.auth.basic '704ef231-cd93-49c9-a201-26b4b5d0d35b', '0342a546-e0c2-0dff-f0be-6a5e17154033' client.get(path: '/ExternalApi/v2/production/order/run', query: [ ProductionOrderID: '1c634596-eb51-4ff1-828b-ee1b42a9a5f1' ], accept: 'application/json') { resp, reader -> response.data = new JsonSlurper().parse(reader) println JsonOutput.prettyPrint(JsonOutput.toJson(response.data)) } ``` -------------------------------- ### C# Example for Get Production Run Source: https://dearinventory.docs.apiary.io/reference/production/production-run/get Example of how to retrieve production run data using C#. This snippet uses HttpClient to perform the GET request. ```C# using System; using System.Net.Http; using System.Threading.Tasks; public class Example { public static async Task Main(){ HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage( HttpMethod.Get, "https://inventory.dearsystems.com/ExternalApi/v2/production/order/run?ProductionOrderID=1c634596-eb51-4ff1-828b-ee1b42a9a5f1" ); request.Headers.Add("api-auth-accountid", "704ef231-cd93-49c9-a201-26b4b5d0d35b"); request.Headers.Add("api-auth-applicationkey", "0342a546-e0c2-0dff-f0be-6a5e17154033"); HttpResponseMessage response = await client.SendAsync(request); if (response.IsSuccessStatusCode) { string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } } ``` -------------------------------- ### Authentication and Sale List Example Source: https://dearinventory.docs.apiary.io/reference/product-categories/product-category This snippet demonstrates how to authenticate with the Dear Systems API using account ID and application key, and how to make a GET request to retrieve a list of sales. ```APIDOC ## Connecting to the API To use the API you will need your Cin7 Core Account ID and API Application key. These can be created on the API setup page inside Cin7 Core Inventory application: https://inventory.dearsystems.com/ExternalAPI. Each company that you have access to in Cin7 Core Inventory will have a different Cin7 Core Account ID. You can have multiple API Applications created on the same Cin7 Core account. This allows you to link different applications/add-ons to Cin7 Core, since API limits are applied on per API Application basis. Your Account ID and API Application Key are equivalent to a login and password. They must be kept secret and not shared in any way. Each request to the API must include these two values sent as HTTP headers: * api-auth-accountid - You must send your Account ID in this header. * api-auth-applicationkey - You must send API Application Key in this header. ### GET SaleList Retrieves a list of sales. #### Method GET #### Endpoint /ExternalApi/v2/SaleList #### Query Parameters - **Page** (string) - Optional - The page number to retrieve. - **Limit** (string) - Optional - The number of results per page. #### Headers - **api-auth-accountid** (string) - Required - Your Cin7 Core Account ID. - **api-auth-applicationkey** (string) - Required - Your API Application Key. - **Content-type** (string) - Required - Set to "application/json". ### Request Example (PHP) ```php $account_id = 'api-auth-accountid: youraccountid'; $application_key = 'api-auth-applicationkey: applicationkey'; $naked_dear_url = 'https://inventory.dearsystems.com/ExternalApi/v2/SaleList'; $data = array ('Page' => '1', 'Limit' => '100'); $data = http_build_query($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$naked_dear_url."?வுகளை"); //GET API CALL curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $headers = [ "Content-type: application/json", $account_id, $application_key ]; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $server_output = curl_exec ($ch); curl_close ($ch); print $server_output ; ``` ``` -------------------------------- ### Start Workflow C# Request Source: https://dearinventory.docs.apiary.io/reference/crm/start-a-workflow/post Example of starting a workflow using C#'s HttpClient. This snippet demonstrates how to send a POST request with appropriate headers and body. ```csharp using System; using System.Net.Http; using System.Text; using System.Threading.Tasks; public class WorkflowStarter { public static async Task StartWorkflowAsync() { var url = "https://inventory.dearsystems.com/ExternalApi/v2/crm/workflowstart?ID=ID&Name=Name&StartDate=StartDate&EnityType=EnityType&EntityID=EntityID"; var headers = new Dictionary { { "Content-Type", "application/json" }, { "api-auth-accountid", "704ef231-cd93-49c9-a201-26b4b5d0d35b" }, { "api-auth-applicationkey", "0342a546-e0c2-0dff-f0be-6a5e17154033" } }; var body = "{}"; using (var client = new HttpClient()) { var request = new HttpRequestMessage(HttpMethod.Post, url); foreach (var header in headers) { request.Headers.Add(header.Key, header.Value); } request.Content = new StringContent(body, Encoding.UTF8, "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } } ```