jundis / CWSlack-SlashCommands

Retrieve ConnectWise information into Slack channels and DMs
GNU General Public License v3.0
54 stars 21 forks source link

Error pulling project tickets since CW Update #134

Open justinDJC opened 5 years ago

justinDJC commented 5 years ago

Hiya!

Fantastic script, very useful.

having some issues since updating to 2019.3, specifically with /t command on our project tickets. Normal tickets work fine.

Notice: Undefined property: stdClass::$_info in [removed]/cw-slack/cwslack.php on line 749

Notice: Trying to get property of non-object in [removed]/cw-slack/cwslack.php on line 749

malformed

Is the result we get. Enabling debug mode, the output is:

string(1070) "HTTP/1.1 404 Not Found Cache-Control: no-cache Pragma: no-cache Content-Length: 67 Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/8.0 x-server-name: SERVER2012 x-cw-request-id: 7afd5c02-98d1-44e2-96b5-972e3b6182b5 api-current-version: 2019.3 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET X-Content-Type-Options: nosniff X-Xss-Protection: 1; mode=block Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval' blob: .connectwise .connectwise.com .appcues.com az416426.vo.msecnd.net dc.services.visualstudio.com/v2/track .appcues.net .connectwisedev.com .myconnectwise.net cwview.com .wise-pay.com .wise-sync.com; font-src 'self' 'unsafe-inline' 'unsafe-eval' .connectwise.com .googleapis.com; img-src data: snapshot:; frame-src data:; connect-src 'self' .connectwise.com .connectwisedev.com .myconnectwise.net cwview.com .appcues.net wss://.appcues.net cheetah quotewerks://; Date: Wed, 05 Jun 2019 06:25:23 GMT

{ "code": "NotFound", "message": "Ticket 457671 not found" }" string(1592) "HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Length: 587 Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/8.0 x-server-name: SERVER2012 x-cw-request-id: ae6304ee-40b0-46f2-9502-12fccc25fdfa Link: api-current-version: 2019.3 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET X-Content-Type-Options: nosniff X-Xss-Protection: 1; mode=block Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval' blob: .connectwise .connectwise.com .appcues.com az416426.vo.msecnd.net dc.services.visualstudio.com/v2/track .appcues.net .connectwisedev.com .myconnectwise.net cwview.com .wise-pay.com .wise-sync.com; font-src 'self' 'unsafe-inline' 'unsafe-eval' .connectwise.com .googleapis.com; img-src data: snapshot:; frame-src data:; connect-src 'self' .connectwise.com .connectwisedev.com .myconnectwise.net cwview.com .appcues.net wss://.appcues.net cheetah quotewerks://; Date: Wed, 05 Jun 2019 06:25:23 GMT

[{"id":699415,"ticketId":457671,"text":"Assigned / je / Assigning ticket","detailDescriptionFlag":false,"internalAnalysisFlag":true,"resolutionFlag":false,"member":{"id":174,"identifier":"PM","name":"DJC Project Manager","_info":{"member_href":"https://portal.djc.com.au/v4_6_release/apis/3.0/system/members/174","image_href":"https://portal.djc.com.au/v4_6_release/apis/3.0/system/members/174/image?lm=2018-11-13T00:33:23Z"}},"dateCreated":"2019-05-23T03:55:12Z","createdBy":"PM","internalFlag":true,"externalFlag":false,"_info":{"lastUpdated":"2019-05-23T03:55:12Z","updatedBy":"PM"}}]" string(1081) "HTTP/1.1 400 Bad Request Cache-Control: no-cache Pragma: no-cache Content-Length: 76 Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/8.0 x-server-name: SERVER2012 x-cw-request-id: f43a4418-cfb9-451f-a9a2-abf188da47e6 api-current-version: 2019.3 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET X-Content-Type-Options: nosniff X-Xss-Protection: 1; mode=block Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval' blob: .connectwise .connectwise.com .appcues.com az416426.vo.msecnd.net dc.services.visualstudio.com/v2/track .appcues.net .connectwisedev.com .myconnectwise.net cwview.com .wise-pay.com .wise-sync.com; font-src 'self' 'unsafe-inline' 'unsafe-eval' .connectwise.com .googleapis.com; img-src data: snapshot:; frame-src data:; connect-src 'self' .connectwise.com .connectwisedev.com .myconnectwise.net cwview.com .appcues.net wss://.appcues.net cheetah quotewerks://; Date: Wed, 05 Jun 2019 06:25:23 GMT

{ "code": "InvalidOrderBy", "message": "Unrecognized orderBy field" }"

Notice: Undefined property: stdClass::$_info in [removed]/cw-slack/cwslack.php on line 749

Notice: Trying to get property of non-object in [removed]/cw-slack/cwslack.php on line 749 bool(false)

malformed

Any help would be appreciated.

justinDJC commented 5 years ago

Further to the above.

I've found that in the API logs, it looks like its trying to look up the ticket as though it was a service ticket, but the API needs to be looking at in in the project area. Perhaps they made changes to the API?

404 (NotFound) GET https://portal.djc.com.au/v4_6_release/apis/3.0/service/tickets/473050

If i log in in by browser and change service to project, i get data.

kenoyer130 commented 5 years ago

For security reasons we no longer return project tickets with the ticket endpoint. For project tickets you have to hit the project ticket endpoint. Let me know if you run into any issues! Note for legacy reasons we kept the TicketType field but it only supports a type of Ticket now.

On Fri, Jun 21, 2019 at 7:39 AM justinDJC notifications@github.com wrote:

Further to the above.

I've found that in the API logs, it looks like its trying to look up the ticket as though it was a service ticket, but the API needs to be looking at in in the project area. Perhaps they made changes to the API? 404 (NotFound) GET https://portal.djc.com.au/v4_6_release/apis/3.0/service/tickets/473050

If i log in in by browser and change service to project, i get data.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jundis/CWSlack-SlashCommands/issues/134?email_source=notifications&email_token=AAB4WFX6IGXH5RSXQBFY6VDP3S4WJA5CNFSM4HTQVIHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYIHMAA#issuecomment-504395264, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB4WFWVWXXKUA2LET7T253P3S4WJANCNFSM4HTQVIHA .

jundis commented 5 years ago

@justinDJC Sorry for the delay on this, I should have a patch in for this sometime this week or next week.

justinDJC commented 5 years ago

Legend. Thanks mate.

jundis commented 5 years ago

@justinDJC Still delayed. We're stuck on 2019.1 currently due to our server still being 2008r2. Currently working to figure out a migration plan with CW, and once that's done I'll have an update in for this.

justinDJC commented 5 years ago

No stress at all mate. Thanks for the update :)

jundis commented 5 years ago

We're finally on it. I'll have an update for this sometime this week, sorry for the delays.

jundis commented 5 years ago

@justinDJC Bit of an idiot and could've had this workaround for you a while ago, sorry. If you set functions.php to have $globalVersion = "2019.2"; on line 29 instead of 2019.3, it should work while I make a patch.

justinDJC commented 5 years ago

Hi Mate!

No stress at all. I gave your quick fix a go and the error changed to:

Notice: Undefined property: stdClass::$dateEntered in -------/cw-slack/cwslack.php on line 776

Line 776 is: $date=strtotime($dataTData->_info->dateEntered); //Convert date entered JSON result to time.

I'll await your update :)

jundis commented 5 years ago

@justinDJC Updated files should correct those issues. Replace the main cwslack file, incoming, timealerts, and time. I also updated functions to correctly say 2019.2 for API version