You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever I create a new resource/entity I am supposed to get the created resource/entity id in the response but instead I am getting empty({}) response. The response is showing 200 status. Also I checked, the record is indeed getting created in the autotask.
This is the code I am using
public function createContact()
{
$contact = new ContactEntity(
[
'id' => 0, // Autotask requires that new entities have an ID of 0
'companyID' => 0,
'firstName' => 'New',
'lastName' => 'User',
'isActive' => 1,
]
);
try {
$response = $this->autoTaskClient->contacts()->create($contact);
return response()->json($response);
} catch (\Exception $exception) {
return $exception->getMessage();
}
}
It returned {} only.
The text was updated successfully, but these errors were encountered:
Did you figure this out as I too am having the same issue. I am creating a ticket and then need to go and add time entries to the ticket but dont have a created entity ID.
PS. I figured this out. The "response" returned from the initial query is just the Guzzle stream. You need to call getBody() on the Guzzle response stream to get the actual server response in JSON.
So i.e.
...
$response = $client->tickets()->create( $ticket );
$contents = (string) $response->getBody();
echo $contents;
...
$contents will contain a string of the raw json response (like {"itemId":10018}). Obviously not very helpful as a string but this was just for testing. Do with it as you please.
I believe this should be the same for any entity :).
Whenever I create a new resource/entity I am supposed to get the created resource/entity id in the response but instead I am getting empty({}) response. The response is showing 200 status. Also I checked, the record is indeed getting created in the autotask.
This is the code I am using
It returned {} only.
The text was updated successfully, but these errors were encountered: