Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error calling New-AutotaskBody after Get-AutotaskAPIResource #49

Open
LedgerLand opened this issue Dec 9, 2022 · 1 comment
Open

Error calling New-AutotaskBody after Get-AutotaskAPIResource #49

LedgerLand opened this issue Dec 9, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@LedgerLand
Copy link

LedgerLand commented Dec 9, 2022

I have run into what I believe is a bug when trying to create a new resource object. In my specific case, these are the commands to reproduce the issue:

Add-AutotaskAPIAuth -ApiIntegrationcode $ATTrackingApi -credentials $ATCredentials
$companyDetail = Get-AutotaskAPIResource -Resource Companies -SimpleSearch "id eq 0"
$newCompany = New-AutotaskBody -Resource Companies -NoContent

These steps produce the following error:

New-AutotaskBody : Getting object failed: The remote server returned an error: (404) Not Found.
At line:1 char:11
+ $ticket = New-AutotaskBody -Resource Companies -NoContent
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-AutotaskBody

I am writing using Visual Studio Code on a Windows 11 Pro workstation. Below is the PowerShell version table:

Name                           Value
----                           -----
PSVersion                      5.1.22621.608
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.608
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

If I re-run the command "Add-AutotaskAPIAuth -ApiIntegrationcode $ATTrackingApi -credentials $ATCredentials -VerboseAdd-AutotaskAPIAuth -ApiIntegrationcode $ATTrackingApi -credentials $ATCredentials" after the Get request the issue does not happen.

Equally, if you try and create a different resource to the one queried (ie. query tickets but create a company) then this does not happen.

If you need anymore details just let me know :-)

@LedgerLand LedgerLand added the bug Something isn't working label Dec 9, 2022
@phill-holbrook
Copy link
Contributor

phill-holbrook commented Jan 11, 2023

I can confirm and reproduce this bug using the Contracts entity:

$Data = Get-AutotaskAPIResource -Resource Contracts -SearchQuery $filter
$Body = New-AutotaskBody -Resource Contracts
New-AutotaskBody: Getting object failed: Response status code does not indicate success: 404 (Not Found).

After re-authenticating using Add-AutotaskAPIAuth:

$Body = New-AutotaskBody -Resource Contracts

There must be something in Get-AutotaskAPIResource that's breaking a script variable or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants