[ZBX-17490] CurlHttpRequest method is not working with http-url-encoded URIs Created: 2020 Mar 21 Updated: 2024 Apr 10 Resolved: 2021 May 18 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S), Templates (T) |
Affects Version/s: | 4.4.6 |
Fix Version/s: | None |
Type: | Problem report | Priority: | Trivial |
Reporter: | Leonid | Assignee: | Zabbix Development Team |
Resolution: | Duplicate | Votes: | 2 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
CentOS 7.7.1908, postgreSQL 9.2.24 |
Attachments: |
![]() |
||||||||
Issue Links: |
|
||||||||
Team: | |||||||||
Sprint: | Sprint 62 (Mar 2020), Sprint 63 (Apr 2020), Sprint 64 (May 2020), Sprint 65 (Jun 2020), Sprint 66 (Jul 2020), Sprint 67 (Aug 2020), Sprint 68 (Sep 2020), Sprint 69 (Oct 2020), Sprint 70 (Nov 2020), Sprint 71 (Dec 2020), Sprint 72 (Jan 2021), Sprint 73 (Feb 2021), Sprint 74 (Mar 2021), Sprint 75 (Apr 2021) |
Description |
Steps to reproduce:
Result:
Comment: ** After some investigations i've found the reason. function getPermalink(channelId, messageTimestamp) { var req = new CurlHttpRequest(); req.AddHeader('Content-Type: application/x-www-form-urlencoded; charset=utf-8'); req.AddHeader('Authorization: Bearer ' + params.bot_token); var resp = JSON.parse(req.Get('\{0}?Ftoken=\{1}&channel=\{2}&message_ts=\{3}'.format( Slack.getPermalink, params.bot_token, channelId, messageTimestamp ));); if (req.Status != 200 && !resp.ok) { throw resp.error; } return resp.permalink; } CurlHTTPRequest method is not working properly with urlencoded URI, in result it fails to get good answer from server and get plain-text HTML instead of JSON, so script falls with error. |
Comments |
Comment by kaihei sameshima [ 2020 Apr 24 ] |
I solved it in the following way. var resp = JSON.parse(req.Get(url, "")); var resp = JSON.parse(req.Get(url, "")); |
Comment by Leonid [ 2020 Apr 30 ] |
@kaihei777 thank you, fixed it with your suggestion, so it's template issue, not server itself. |
Comment by Leonid [ 2020 May 05 ] |
Fixed template: media_slack.xml |
Comment by Aleksandrs Larionovs (Inactive) [ 2021 May 14 ] |
Resolved in |