![]() |
VOOZH | about |
The CData Cmdlets for eBay are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to eBay.
The Cmdlets are not only a PowerShell interface to eBay, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete eBay data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for eBay. To access eBay data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for eBay.
Once you have acquired the necessary connection properties, accessing eBay data in PowerShell can be enabled in three steps.
If you will be accessing your own account, you can generate an OAuthAccessToken from your developer account dashboard. You can also allow other users to securely access their own accounts.
Both of these methods require you to create an application key set to obtain values for the following connection properties: AppId, CertId, DevId, and SiteId.
The user consent flow additionally requires the RuName and CallbackURL.
See the "Getting Started" chapter in the help documentation for a guide to using OAuth.
Install the module:
Install-Module EbayCmdlets
Connect:
$ebay = Connect-Ebay -AppId "$AppId" -CertId "$CertId" -DevId "$DevId" -SiteId "$SiteId" -RuName "$RuName" -CallbackURL "$CallbackURL" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$listingstatus = "active" $itemlisting = Select-Ebay -Connection $ebay -Table "ItemListing" -Where "ListingStatus = `'$ListingStatus`'" $itemlisting
You can also use the Invoke-Ebay cmdlet to execute SQL commands:
$itemlisting = Invoke-Ebay -Connection $ebay -Query 'SELECT * FROM ItemListing WHERE ListingStatus = @ListingStatus' -Params @{'@ListingStatus'='active'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for eBay\lib\System.Data.CData.Ebay.dll")
Connect to eBay:
$conn= New-Object System.Data.CData.Ebay.EbayConnection("AppId=MyAppId;CertId=MyCertId;DevId=MyDevId;SiteId=MySiteId;RuName=MyRuName;CallbackURL=http://localhost:33333;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the EbayDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Title, HitCount from ItemListing"
$da= New-Object System.Data.CData.Ebay.EbayDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.title $_.hitcount
}
Update-Ebay -Connection $Ebay -Columns @('Title','HitCount') -Values @('MyTitle', 'MyHitCount') -Table ItemListing -Id "MyId"
$cmd = New-Object System.Data.CData.Ebay.EbayCommand("UPDATE ItemListing SET ListingStatus='active' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Ebay.EbayParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-Ebay -Connection $Ebay -Table ItemListing -Columns @("Title", "HitCount") -Values @("MyTitle", "MyHitCount")
$cmd = New-Object System.Data.CData.Ebay.EbayCommand("INSERT INTO ItemListing (ListingStatus) VALUES (@myListingStatus)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Ebay.EbayParameter("@myListingStatus","active")))
$cmd.ExecuteNonQuery()
Remove-Ebay -Connection $Ebay -Table "ItemListing" -Id "MyId"
$cmd = New-Object System.Data.CData.Ebay.EbayCommand("DELETE FROM ItemListing WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Ebay.EbayParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the eBay Data Provider to get started:
Download NowLearn more:
👁 eBay IconRapidly create and deploy powerful .NET applications that integrate with eBay auction data including Items, Bidders, Transactions, and more!