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

TicketAttachment Data is empty #69

Open
Darrrren opened this issue Sep 16, 2022 · 2 comments
Open

TicketAttachment Data is empty #69

Darrrren opened this issue Sep 16, 2022 · 2 comments
Labels
needs info Needs more information.

Comments

@Darrrren
Copy link
Contributor

When requesting a TicketAttachment, the fields returned and their contents are all correct. However the data: field is null

Here's an example response:

Anteris\Autotask\API\TicketAttachments\TicketAttachmentCollection {#1249
  #items: array:1 [
    0 => Anteris\Autotask\API\TicketAttachments\TicketAttachmentEntity {#1231
      #exceptKeys: []
      #onlyKeys: []
      +attachDate: Carbon\Carbon @1663332465 {#1242
        #endOfTime: false
        #startOfTime: false
        #constructedObjectId: "00000000000004da0000000000000000"
        #localMonthsOverflow: null
        #localYearsOverflow: null
        #localStrictModeEnabled: null
        #localHumanDiffOptions: null
        #localToStringFormat: null
        #localSerializer: null
        #localMacros: null
        #localGenericMacros: null
        #localFormatFunction: null
        #localTranslator: null
        #dumpProperties: array:3 [
          0 => "date"
          1 => "timezone_type"
          2 => "timezone"
        ]
        #dumpLocale: null
        #dumpDateProperties: null
        date: 2022-09-16 12:47:45.607 +00:00
      }
      +attachedByContactID: null
      +attachedByResourceID: 29682955
      +attachmentType: "FILE_ATTACHMENT"
      +contentType: "image/png"
      +creatorType: 1
      +data: null
      +fileSize: 2359088.0
      +fullPath: "filetest.png"
      +id: 296079
      +impersonatorCreatorResourceID: null
      +opportunityID: null
      +parentAttachmentID: null
      +parentID: 72529
      +publish: 1
      +ticketID: 72529
      +ticketNoteID: null
      +timeEntryID: null
      +title: "Test Image"
      +userDefinedFields: null
    }
  ]
  #escapeWhenCastingToString: false
}

When querying the API directly, the data field contains the expected data:

Request:

$ticketid = 72529;
$attachmentid = 296079;

$atClient = new Client([
    'base_uri' => getenv('AT_URL'),
        'headers' => [
            'ApiIntegrationCode' => getenv('AT_INTEGRATIONCODE'),
            'UserName' => getenv('AT_USERNAME'),
            'Secret' => getenv('AT_SECRET'),
            'Content-Type' => 'application/json'
        ]
]);
$result = $atClient->request('GET','v1.0/Tickets/'.$ticketid.'/Attachments/'.$attachmentid);
$responseArray = json_decode($result->getBody(),true);
dump($responseArray);

Response:

 array:2 [
  "items" => array:1 [
    0 => array:19 [
      "id" => 296079
      "attachDate" => "2022-09-16T08:47:45.607"
      "attachedByContactID" => null
      "attachedByResourceID" => 29682955
      "attachmentType" => "FILE_ATTACHMENT"
      "contentType" => "image/png"
      "creatorType" => 1
      "fileSize" => 2359088.0
      "fullPath" => "filetest.png"
      "impersonatorCreatorResourceID" => null
      "opportunityID" => null
      "parentAttachmentID" => null
      "parentID" => 72529
      "publish" => 1
      "ticketID" => 72529
      "ticketNoteID" => null
      "timeEntryID" => null
      "title" => "Test Image"
      "data" => "iVBORw0KGgoAAAANSUhEUgAACpUAAAZFCAYAAADC48neAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAP+lSURBVHhe7P0HgB3Jdd6LFzDAYJAzFgtsxubITQxLLpNEUSIpJksiRcuWbFqWnBT5pOf4+H96z7IsW8GSJcvys2XJSpRoSqJIUWLOy8057wK7CyyARc4zgwH2f74Tqqv79k0zAyyW/H4z3VV16tSpU9V1+/adPtN3zo5de19MhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIeRbmrmeEkIIIYQQQgghhBBCCCGEEEIIIYQQQgghhJBvYRhUSgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIYVEoIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCGFRKCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgQGlRJCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQBpUSQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEAaVEkIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBCBQaWEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhEGlhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYRBpYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCFEYFApIYQQQgghhBB............ blah blah blah
Y8yfXIm36tfWO655bD8Wn8Wz5M2ZnPZsNiN5D9xkhvOSDvexobHt5qKKbI4Y5oY2jNak6lGTFh9rc/vfHjbNTuPnx2WzaKazyopoVNvsgg5cQqHr4DS30bre8D2wybR2Cr14Yjvj3tk+Fsynz9fP3ssLiSlY3ZWYR/lc6vtXArSUtag/G5R2XzaYjwXp2BmbfpMPq1vs5nPU+759zGAnI++9fiZ/DaOZzleAvrsoL8/xebQjuqjzNO6DT4LkMg954kyZw1g2BL8bNtaKZasZyS7hXnQX3t/dvo+C+CWH5yUj9/kj5yJSz6ddidPPbMs+OhydvtrH+8AfT7ccn/U5he1LBqUJ8G0vryM/y2dz8uOiZz/fs/4/u/LD/cSduSNzVhbVU631kmshK1Z21Vet9ZJrIS2xR0pcqZn09nPUSoYOaP1/eAe+ffv/TGMpvMyqxK4AAAAASUVORK5CYII="
    ]
  ]
  "pageDetails" => array:4 [
    "count" => 1
    "requestCount" => 1
    "prevPageUrl" => null
    "nextPageUrl" => null
  ]
]      
@aidan-casey
Copy link
Member

@Darrrren - Sorry this has sat so long. 😅 Is this still a problem?

@aidan-casey aidan-casey added the needs info Needs more information. label May 24, 2023
@msullivanJIT
Copy link

msullivanJIT commented Aug 25, 2023

There's definitely an issue.

Using TicketAttachments()->findById($id)

In TicketAttachmentEntity->fromResponse() the response returned from getBody() includes ["items"] (plural) and the isset() === false is testing against ['item']; throwing the "Missing item key in response" exception.

returning $responseArray["items"][0] of course works, but that wouldn't be the best way to handle an array of items.

TicketAttachmentCollection also has no data for me too as Darrrren pointed out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info Needs more information.
Projects
None yet
Development

No branches or pull requests

3 participants