This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This WebSession object was not generated by Postman but you will need it to | |
#Share the Session state across each of the ReST calls. These calls will not | |
#Work without it | |
$WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession | |
#We need this header data that Postman generated for us | |
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" | |
$headers.Add("Content-Type", "application/json") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#We will declare Variable that will change often up at the top | |
#This is a common practice for scripts. | |
#Later we will convert this to a function, and these will become parameters | |
$AcumaticaUser = "Admin" | |
$AcumaticaPassword = "123" | |
$AcumaticaTenant = "Company" | |
$AcumaticaEndPoint = "http://localhost/APS20_104_0012" | |
$ReferenceNbr = "AR008403" | |
$WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$CustomerNbr = "ABARTENDE" | |
$Description = "This was auto created with PowerShell" | |
$InventoryID = "CONSULTING" | |
$Qty = "1.000000" | |
$UnitPrice = "100.000000" | |
$UOM = "HOUR" | |
#The @" and "@ tags declare a here string which allows you to have string declarations that run multiple lines | |
$body = @" | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Releasing Invoice $ReferenceNbr" | |
$body = @" | |
{ | |
`"entity`":{`"id`": `"$EntityID`"} | |
} | |
$body | |
"@ | |
$HashArguments = @{ | |
Uri = "$AcumaticaEndPoint/entity/default/18.200.001/Invoice/ReleaseInvoice" | |
Method = 'POST' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Create A payment for invoice $ReferenceNbr" | |
$body = @" | |
{ | |
`"Type`": {`"value`": `"Payment`"}, | |
`"CustomerID`": {`"value`": `"$CustomerNbr`"}, | |
`"PaymentMethod`": {`"value`": `"$PaymentMethod`"}, | |
`"PaymentAmount`": {`"value`": $UnitPrice}, | |
`"DocumentsToApply`": [{`"ReferenceNbr`": {`"value`": `"$ReferenceNbr`"}}] | |
} | |
"@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Login-Acumatica | |
{ | |
#This OutputType allows you to strongly type the return object from this function | |
#In this case we are going to encapsulate the WebRequestSession object initialization and return it | |
#to the calling process as to be used in other functions. This is needed as to pass the authentication | |
#State to other functions that need it. Don’t forget to use the Logout-Acumatica function else you will incur | |
#unnecessary User Logins if they are left open. | |
[OutputType([Microsoft.PowerShell.Commands.WebRequestSession])] | |
param( | |
$User = $Null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Logout-Acumatica | |
{ | |
param( | |
[Parameter(Mandatory=$true)] | |
[Microsoft.PowerShell.Commands.WebRequestSession]$WebSession, | |
$EndPoint = $env:AcumaticaTestEndPoint | |
) | |
$Uri = "$EndPoint/entity/auth/logout" | |
$response = Invoke-RestMethod $Uri -Method 'POST' -Headers $headers -WebSession $WebSession |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-Invoice | |
{ | |
param( | |
[Parameter(Mandatory=$true)] | |
[Microsoft.PowerShell.Commands.WebRequestSession]$WebSession, | |
$EndPoint = $env:AcumaticaTestEndPoint, | |
[Parameter(Mandatory=$true)] | |
$ReferenceNbr) | |
$HashArguments = @{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Create-Invoice | |
{ | |
param( | |
[Parameter(Mandatory=$true)] | |
[Microsoft.PowerShell.Commands.WebRequestSession]$WebSession, | |
$EndPoint = $env:AcumaticaTestEndPoint, | |
$Body, | |
[switch]$release) | |
$Uri = "$EndPoint/entity/default/18.200.001/Invoice" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Pay-Invoice | |
{ | |
param( | |
[Parameter(Mandatory=$true)] | |
[Microsoft.PowerShell.Commands.WebRequestSession]$WebSession, | |
$EndPoint = $env:AcumaticaTestEndPoint, | |
[Parameter(Mandatory=$true)] | |
[string]$ReferenceNbr, | |
[Parameter(Mandatory=$true)] | |
[string]$PaymentMethod) |
OlderNewer