Tradera Developer Program

Adding an item (Auction)

For adding a shop item please see AddShopItem.

RestrictedService requires the use of a authorization token. Please read the Authentication and authorization before continuing.

There are two possible methods to use when adding an Item, AddItem and AddItemXml. The XML version should only be used by clients that cannot send SOAP objects.

When adding an Item, a request is placed in a queue, which is then processed by the Tradera system. If you want to add images to the Item, you need to set the property AutoCommit to false on the ItemRequest, and then call the method AddItemImage for each image. When done, call AddItemCommit. Note that the call to AddItemCommit is not necessary if AutoCommit was set to true when you added the Item.

After the Item has been processed, it will, if accepted by the system, either be visible on the main Tradera site or in the Test environment. If the request was rejected, the reason will be visible under the calling Application's log in the Developer Center.

Code example classic ASP

  1:
  2:
  3:
  4:
  5:
  6:
  7:
  8:
  9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 52:
 53:
 54:
 55:
 56:
 57:
 58:
 59:
 60:
 61:
 62:
 63:
 64:
 65:
 66:
 67:
 68:
 69:
 70:
 71:
 72:
 73:
 74:
[STAThread]
static void Main(string[] args) {

	try {
		string appId = "yourAppId"; // Use your application Id
		string appServiceKey = "yourAppServiceKey"; // Use your application service key
		int userId = 0; // The user Id of the user that you want to impersonate
		string token = "yourToken"; // The Token for the specific user and application

		Tradera.Api.RestrictedService restrictedService = new Tradera.Api.RestrictedService();
		restrictedService.Url += string.Format("?appId={0}&appKey={1}", appId, appServiceKey);
		restrictedService.Url += string.Format("&userId={0}&token={1}", userId, token);
		
		// 
		//restrictedService.Url += "&sandbox=1";

		// Add Item without images
		Tradera.Api.ItemRequest itemRequest1 = new Tradera.Api.ItemRequest();
		itemRequest1.Title = "My first Item";
		itemRequest1.Description = "The description for My First Item";
		itemRequest1.AcceptedBidderId = 3; // International
		itemRequest1.StartPrice = 16;
		itemRequest1.ReservePrice = 20;
		itemRequest1.BuyItNowPrice = 50;
		itemRequest1.ExpoItemIds = new int[] { 4 }; // Fetstil 
		itemRequest1.PaymentOptionIds = new int[] { 4096 };
		itemRequest1.CategoryId = 280403; // Ã?vrigt > Specialauktioner > Ã?vrigt
		itemRequest1.Duration = 10; // 10 days
		itemRequest1.OwnRef = "MyOwnReference123";
		itemRequest1.AutoCommit = true;

		restrictedService.AddItem(itemRequest1);

		// Add Item with two images
		Tradera.Api.ItemRequest itemRequest2 = new Tradera.Api.ItemRequest();
		itemRequest2.Title = "My second Item (with images!)";
		itemRequest2.Description = "The description for My second Item";
		itemRequest2.AcceptedBidderId = 3; // International
		itemRequest2.StartPrice = 16;
		itemRequest2.ReservePrice = 20;
		itemRequest2.BuyItNowPrice = 50;
		itemRequest2.ExpoItemIds = new int[] { 2, 3, 4 }; // Minibild, Galleri, Fetstil
		itemRequest2.PaymentOptionIds = new int[] { 4096 };
		itemRequest2.CategoryId = 280403; // Ã?vrigt > Specialauktioner > Ã?vrigt
		itemRequest2.Duration = 11; // 11 days
		itemRequest2.OwnRef = "MyOwnReference124";
		itemRequest2.AutoCommit = false;

		int reservedItemId = restrictedService.AddItem(itemRequest2);

		byte[] byteArray = null;
		using(FileStream fileStream = File.OpenRead(@"Path-To-Image1.jpg")) {
			byteArray = new byte[fileStream.Length];
			fileStream.Read(byteArray, 0, byteArray.Length);
		}
		restrictedService.AddItemImage(reservedItemId, byteArray, Tradera.Api.ImageFormat.Jpeg, true);

		using(FileStream fileStream = File.OpenRead(@"Path-To-Image2.jpg")) {
			byteArray = new byte[fileStream.Length];
			fileStream.Read(byteArray, 0, byteArray.Length);
		}
		restrictedService.AddItemImage(reservedItemId, byteArray, Tradera.Api.ImageFormat.Jpeg, false);

		restrictedService.AddItemCommit(reservedItemId);

		Console.ReadLine();

	} catch(Exception exception) {

		Console.WriteLine("Error: {0}", exception.Message);
		Console.WriteLine(exception.StackTrace);
		Console.ReadLine();
	}
}

Remarks

  • Add your application Id and application service key on lines 5 and 6.
  • Supply the Id and token for the current user on line 7 and 8.
  • Use the name you gave your web reference in place of the Tradera.Api prefix used in lines 10, 18, 35, 56 and 62.

Code example PHP

  1:
  2:
  3:
  4:
  5:
  6:
  7:
  8:
  9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 52:
 53:
 54:
 55:
 56:
 57:
 58:
 59:
 60:
 61:
 62:
 63:
 64:
 65:
 66:
 67:
 68:
 69:
 70:
 71:
 72:
 73:
 74:
 75:
 76:
 77:
 78:
 79:
 80:
 81:
 82:
 83:
 84:
 85:
 86:
 87:
 88:
 89:
 90:
 91:
 92:
 93:
 94:
 95:
 96:
 97:
// Replace tho following variables with your own key management
// $APPLICATION_ID
// $APPLICATION_KEY
// $USER_ID
// $TOKEN
try {
	$appId = $APPLICATION_ID;
	$appKey = $APPLICATION_KEY;
	$userId = $USER_ID;
	$token = $TOKEN;

	$restrictedServiceUrl = 'https://api.tradera.com/v3/RestrictedService.asmx';

	$restrictedServiceUrlWithAuth = $restrictedServiceUrl
					. '?appId=' . $appId
					. '&appKey=' . $appKey
					. '&userId=' . $userId
					. '&token=' . $token;

	$restrictedClient = new SoapClient(
		$restrictedServiceUrl . '?WSDL',
		array('location' => $restrictedServiceUrlWithAuth)
	);

	$addItemParams = new StdClass();

	$itemRequest = new StdClass();
	$itemRequest -> Title = 'Test auction';
	$itemRequest -> OwnReferences = 'abc123';
	$itemRequest -> CategoryId = 344481;
	$itemRequest -> Duration = 4;
	$itemRequest -> Restarts = 0;
	$itemRequest -> StartPrice = 1;
	$itemRequest -> ReservePrice = 0;
	$itemRequest -> BuyItNowPrice = 0;
	$itemRequest -> Description = 'A longer description of the test auction item';
	$itemRequest -> PaymentOptionIds = new StdClass();
	$itemRequest -> PaymentOptionIds -> int = array(4,32,4096);
	
	$shippingOption1 = new StdClass();
	$shippingOption1 -> ShippingOptionId = 1;
	$shippingOption1 -> Cost = 7;
	$shippingOption2 = new StdClass();
	$shippingOption2 -> ShippingOptionId = 8;
	$shippingOption2 -> Cost = 0;
	
	$itemRequest -> ShippingOptions = new StdClass();
	$itemRequest -> ShippingOptions -> ItemShipping = array($shippingOption1, $shippingOption2);
	$itemRequest -> AcceptedBidderId = 1;
	$itemRequest -> ExpoItemIds = new StdClass();
	$itemRequest -> ExpoItemIds -> int = array();
	$itemRequest -> ItemAttributes = new StdClass();
	$itemRequest -> ItemAttributes -> int = array(2);
	$itemRequest -> ItemType = 1;
	$itemRequest -> AutoCommit = false;
	$itemRequest -> VAT = 0;

	$addItemParams -> itemRequest = $itemRequest;

	$addItemResult = $restrictedClient->AddItem($addItemParams);
	$requestId = $addItemResult -> AddItemResult -> RequestId;


	$imageFilePath = 'images/image123.jpeg';
	$imgData =  file_get_contents($imageFilePath);

	$addImageParams = new StdClass();
	$addImageParams -> requestId = $requestId;
	$addImageParams -> imageData = $imgData;
	$addImageParams -> imageFormat = 'Jpeg';
	$addImageParams -> hasMega = true;

	$addItemImageResult = $restrictedClient -> addItemImage($addImageParams);

	$commitItemParams = new StdClass();
	$commitItemParams -> requestId = $requestId;
	$commitItemResult = $restrictedClient->AddItemCommit($commitItemParams);

	sleep(5);
	$getReqResultsParams = new StdClass();
	$getReqResultsParams -> requestIds -> int = array($requestId);
	$requestResult = $restrictedClient -> GetRequestResults($getReqResultsParams);

	$result = $requestResult -> GetRequestResultsResult -> RequestResult;

	if($result -> ResultCode == 'Ok'){
		echo 'SUCCES:' . PHP_EOL . $result -> Message . PHP_EOL;
	}
	else {
		echo 'REQUEST NOT FINISHED:' . $result -> ResultCode . PHP_EOL;
		echo $result -> Message;
	}

} 
catch(SoapFault $soapFault) {
	echo 'Error: ' . $soapFault->faultstring;
}

Remarks

  • Add your application Id, application service key, user Id and user token on lines 7 and 8.
  • Supply the Id and token for the current user on line 9 and 10.

XHTML CSS