createAsset
adds a fixed asset
Adds an asset to the system
/Assets
Usage and SDK Samples
curl -X "https://api.xero.com/assets.xro/1.0/Assets"
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.AssetApi;
import java.io.File;
import java.util.*;
public class AssetApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: OAuth2
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
AssetApi apiInstance = new AssetApi();
String xeroTenantId = xeroTenantId_example; // String | Xero identifier for Tenant
Asset asset = { "assetName":"Computer74863", "assetNumber":"123477544", "purchaseDate":"2020-01-01", "purchasePrice":100.0, "disposalPrice":23.23, "assetStatus":"Draft", "bookDepreciationSetting":{ "depreciationMethod":"StraightLine", "averagingMethod":"ActualDays", "depreciationRate":0.5, "depreciationCalculationMethod":"None" }, "bookDepreciationDetail":{ "currentCapitalGain":5.32, "currentGainLoss":3.88, "depreciationStartDate":"2020-01-02", "costLimit":100.0, "currentAccumDepreciationAmount":2.25 }, "AccountingBookValue":99.5 }; // Asset |
try {
Asset result = apiInstance.createAsset(xeroTenantId, asset);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AssetApi#createAsset");
e.printStackTrace();
}
}
}
import org.openapitools.client.api.AssetApi;
public class AssetApiExample {
public static void main(String[] args) {
AssetApi apiInstance = new AssetApi();
String xeroTenantId = xeroTenantId_example; // String | Xero identifier for Tenant
Asset asset = { "assetName":"Computer74863", "assetNumber":"123477544", "purchaseDate":"2020-01-01", "purchasePrice":100.0, "disposalPrice":23.23, "assetStatus":"Draft", "bookDepreciationSetting":{ "depreciationMethod":"StraightLine", "averagingMethod":"ActualDays", "depreciationRate":0.5, "depreciationCalculationMethod":"None" }, "bookDepreciationDetail":{ "currentCapitalGain":5.32, "currentGainLoss":3.88, "depreciationStartDate":"2020-01-02", "costLimit":100.0, "currentAccumDepreciationAmount":2.25 }, "AccountingBookValue":99.5 }; // Asset |
try {
Asset result = apiInstance.createAsset(xeroTenantId, asset);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AssetApi#createAsset");
e.printStackTrace();
}
}
}
Configuration *apiConfig = [Configuration sharedConfig];
// Configure OAuth2 access token for authorization: (authentication scheme: OAuth2)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
String *xeroTenantId = xeroTenantId_example; // Xero identifier for Tenant (default to null)
Asset *asset = { "assetName":"Computer74863", "assetNumber":"123477544", "purchaseDate":"2020-01-01", "purchasePrice":100.0, "disposalPrice":23.23, "assetStatus":"Draft", "bookDepreciationSetting":{ "depreciationMethod":"StraightLine", "averagingMethod":"ActualDays", "depreciationRate":0.5, "depreciationCalculationMethod":"None" }, "bookDepreciationDetail":{ "currentCapitalGain":5.32, "currentGainLoss":3.88, "depreciationStartDate":"2020-01-02", "costLimit":100.0, "currentAccumDepreciationAmount":2.25 }, "AccountingBookValue":99.5 }; //
AssetApi *apiInstance = [[AssetApi alloc] init];
// adds a fixed asset
[apiInstance createAssetWith:xeroTenantId
asset:asset
completionHandler: ^(Asset output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
const tokenSet: TokenSet = {
id_token: 'xxx',
access_token: 'yyy',
expires_at: 1582308862,
token_type: 'Bearer',
refresh_token: 'zzz',
session_state: 'xxx'
}
await xero.setTokenSet(tokenSet);
const xeroTenantId = "xeroTenantId_example"; // {String} Xero identifier for Tenant
const asset:Asset = { "assetName":"Computer74863", "assetNumber":"123477544", "purchaseDate":"2020-01-01", "purchasePrice":100.0, "disposalPrice":23.23, "assetStatus":"Draft", "bookDepreciationSetting":{ "depreciationMethod":"StraightLine", "averagingMethod":"ActualDays", "depreciationRate":0.5, "depreciationCalculationMethod":"None" }, "bookDepreciationDetail":{ "currentCapitalGain":5.32, "currentGainLoss":3.88, "depreciationStartDate":"2020-01-02", "costLimit":100.0, "currentAccumDepreciationAmount":2.25 }, "AccountingBookValue":99.5 }; // {Asset}
try {
const response: any = await xero.accountingApi.createAsset(xeroTenantId, asset);
console.log(response.body || response.response.statusCode)
} catch (err) {
console.log(`There was an ERROR! \n Status Code: ${err.response.statusCode}.`);
console.log(`ERROR: \n ${JSON.stringify(err.response.body, null, 2)}`);
}
using System;
using System.Diagnostics;
using .Api;
using .Client;
using .Model;
namespace Example
{
public class createAssetExample
{
public void main()
{
// Configure OAuth2 access token for authorization: OAuth2
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new AssetApi();
var xeroTenantId = xeroTenantId_example; // String | Xero identifier for Tenant (default to null)
var asset = new Asset(); // Asset |
try
{
// adds a fixed asset
Asset result = apiInstance.createAsset(xeroTenantId, asset);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling AssetApi.createAsset: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );
$config->setHost("https://api.xero.com/api.xro/2.0");
$xeroTenantId = 'YOUR_XERO_TENANT_ID'; // String | Xero identifier for Tenant
$apiInstance = new XeroAPI\XeroPHP\Api\AssetApi(
new GuzzleHttp\Client(),
$config
);
try {
} catch (Exception $e) {
echo 'Exception when calling AssetApi->createAsset: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use ::Configuration;
use ::AssetApi;
# Configure OAuth2 access token for authorization: OAuth2
$::Configuration::access_token = 'YOUR_ACCESS_TOKEN';
my $api_instance = ::AssetApi->new();
my $xeroTenantId = xeroTenantId_example; # String | Xero identifier for Tenant
my $asset = ::Object::Asset->new(); # Asset |
eval {
my $result = $api_instance->createAsset(xeroTenantId => $xeroTenantId, asset => $asset);
print Dumper($result);
};
if ($@) {
warn "Exception when calling AssetApi->createAsset: $@\n";
}
from __future__ import print_statement
import time
import
from .rest import ApiException
from pprint import pprint
# Configure OAuth2 access token for authorization: OAuth2
.configuration.access_token = 'YOUR_ACCESS_TOKEN'
# create an instance of the API class
api_instance = .AssetApi()
xeroTenantId = xeroTenantId_example # String | Xero identifier for Tenant (default to null)
asset = { "assetName":"Computer74863", "assetNumber":"123477544", "purchaseDate":"2020-01-01", "purchasePrice":100.0, "disposalPrice":23.23, "assetStatus":"Draft", "bookDepreciationSetting":{ "depreciationMethod":"StraightLine", "averagingMethod":"ActualDays", "depreciationRate":0.5, "depreciationCalculationMethod":"None" }, "bookDepreciationDetail":{ "currentCapitalGain":5.32, "currentGainLoss":3.88, "depreciationStartDate":"2020-01-02", "costLimit":100.0, "currentAccumDepreciationAmount":2.25 }, "AccountingBookValue":99.5 } # Asset |
try:
# adds a fixed asset
api_response = api_instance.create_asset(xeroTenantId, asset)
pprint(api_response)
except ApiException as e:
print("Exception when calling AssetApi->createAsset: %s\n" % e)
extern crate AssetApi;
pub fn main() {
let xeroTenantId = xeroTenantId_example; // String
let asset = { "assetName":"Computer74863", "assetNumber":"123477544", "purchaseDate":"2020-01-01", "purchasePrice":100.0, "disposalPrice":23.23, "assetStatus":"Draft", "bookDepreciationSetting":{ "depreciationMethod":"StraightLine", "averagingMethod":"ActualDays", "depreciationRate":0.5, "depreciationCalculationMethod":"None" }, "bookDepreciationDetail":{ "currentCapitalGain":5.32, "currentGainLoss":3.88, "depreciationStartDate":"2020-01-02", "costLimit":100.0, "currentAccumDepreciationAmount":2.25 }, "AccountingBookValue":99.5 }; // Asset
let mut context = AssetApi::Context::default();
let result = client.createAsset(xeroTenantId, asset, &context).wait();
println!("{:?}", result);
}
Scopes
assets |
Parameters
Name | Description |
---|---|
Xero-Tenant-Id* |
String
Xero identifier for Tenant
Required
|
Name | Description |
---|---|
asset * |
Asset
Fixed asset you are creating
Required
|