Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-17490

CurlHttpRequest method is not working with http-url-encoded URIs

    XMLWordPrintable

Details

    • Problem report
    • Status: Closed
    • Trivial
    • Resolution: Duplicate
    • 4.4.6
    • None
    • Server (S), Templates (T)
    • None
    • CentOS 7.7.1908, postgreSQL 9.2.24
    • Team INT
    • 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:

      1. Create Slack media with instructions from https://www.zabbix.com/integrations/slack
      2. Problem message sent, but reported as non-sent because of  error: SyntaxError: invalid json (at offset 1)
      3. Resolve messages is not sent at all, error - channel_not_found

      Result:
              Messages in Slack is not working as expected
      Expected:
             Messages sends to Slack without errors, resolve and update works too

       

      Comment:

       ** After some investigations i've found the reason.
      Part of script from tutorial tries to get permalink for Slack message to attach it as tag to Problem in Zabbix:

      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.

      Attachments

        Issue Links

          Activity

            People

              zabbix.dev Zabbix Development Team
              Leonik Leonid
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: