Closed matiaso closed 4 years ago
When sending a message using the PHP Library, I receive a 500 error:
[Google_Service_Exception] { "error": { "code": 500, "message": "Internal error encountered.", "errors": [ { "message": "Internal error encountered.", "domain": "global", "reason": "backendError" } ], "status": "INTERNAL" } }
Code sample:
$client = new Google_Client(); $client->setApplicationName('App Name'); $client->setScopes('https://www.googleapis.com/auth/chat.bot'); $client->setAuthConfig('credentials.json'); $client->setSubject('me@mycompany.com'); $spaces = $hangoutChat->spaces->listSpaces()->getSpaces(); /** @var \Google_Service_HangoutsChat_Space $space */ foreach ($spaces as $space){ $message = new \Google_Service_HangoutsChat_Message(); $message->setText('This is a test'); $hangoutChat->spaces_messages->create($space->getName(), $message); }
With the same parameters using the Java library I am able to send a message. I am not expecting to receive a 500 error.
The list of spaces is retrieved correctly and the name is also correct.
Here is the content of the request: {"text":"This is a test"}
{"text":"This is a test"}
And the Headers:
POST https://chat.googleapis.com/v1/spaces/AAAspaceName/messages Host: chat.googleapis.com content-type: application/json User-Agent: App Name google-api-php-client/2.4.1 x-goog-api-client: gl-php/7.1.3 gdcl/2.4.1 authorization: Bearer thisIstheBearerOhYeah123thisIstheBearerOhYeah123.again.thisIstheBearerOhYeah123 Content-Length: 25 Vary: X-Origin Vary: Referer Content-Type: application/json; charset=UTF-8 Date: Wed, 15 Apr 2020 15:47:18 GMT Server: ESF Cache-Control: private X-XSS-Protection: 0 X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff Alt-Svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,h3-T050=":443"; ma=2592000 Accept-Ranges: none Vary: Origin,Accept-Encoding Transfer-Encoding: chunked
Edit:
It appears to be linked to the bearer generated. When I use the bearer from PHP it returns an error, if I use the one generated by Java, it works,
Solved: I removed $client->setSubject('me@mycompany.com')
$client->setSubject('me@mycompany.com')
When sending a message using the PHP Library, I receive a 500 error:
Code sample:
With the same parameters using the Java library I am able to send a message. I am not expecting to receive a 500 error.
The list of spaces is retrieved correctly and the name is also correct.
Here is the content of the request:
{"text":"This is a test"}
And the Headers:
POST https://chat.googleapis.com/v1/spaces/AAAspaceName/messages Host: chat.googleapis.com content-type: application/json User-Agent: App Name google-api-php-client/2.4.1 x-goog-api-client: gl-php/7.1.3 gdcl/2.4.1 authorization: Bearer thisIstheBearerOhYeah123thisIstheBearerOhYeah123.again.thisIstheBearerOhYeah123 Content-Length: 25 Vary: X-Origin Vary: Referer Content-Type: application/json; charset=UTF-8 Date: Wed, 15 Apr 2020 15:47:18 GMT Server: ESF Cache-Control: private X-XSS-Protection: 0 X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff Alt-Svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,h3-T050=":443"; ma=2592000 Accept-Ranges: none Vary: Origin,Accept-Encoding Transfer-Encoding: chunked
Edit:
It appears to be linked to the bearer generated. When I use the bearer from PHP it returns an error, if I use the one generated by Java, it works,