Open Ash-raf10 opened 1 year ago
@Ash-raf10 - What is the response on this same request using something like Postman?
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.
(Credit to - https://stackoverflow.com/questions/30549226/guzzlehttp-how-get-the-body-of-a-response-from-guzzle-6)
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.