Hello Monks, I'm facing a weird issue with a script that posts messages on Zendesk. The script has been working for years on Windows 2003 and doesn't on Windows 2016. And yet, the http return code is 200, and no error is returned.
I've checked that there is no network or firewall issues by sending a simple post through curl.
I'm wondering how I can add traces to get clues about what's going wrong.
Here is a test script that fails on W2016 and works on W2003.
Thank you

#!/usr/bin/perl use strict; use LWP::UserAgent; use LWP::Debug qw(+); use JSON; # Zendesk my $netloc = 'xxx.zendesk.com:443'; my $realm = 'Web Password'; my $uname = 'me@mycomp.com/token'; my $pass = 'xxxxxxxxxxx'; my $Server = $ARGV[0]; my $TicketID = "1234"; Comment_Zendesk($TicketID,$Server); exit; sub Comment_Zendesk { my($ZID,$ZServer) = @_; # Create a user agent, and specify the credentials and header of y +our API requests my $ua = LWP::UserAgent->new(); $ua->credentials($netloc, $realm, $uname, $pass); $ua->default_header('Content-Type' => 'application/json'); # Endpoint URL my $url = 'https://xxx.zendesk.com/api/v2/tickets/'.$ZID.'.json'; # Call the API my $body = "Message posted from $ZServer"; my $json = JSON->new->allow_nonref; my $json_body = $json->encode($body); my $data = '{"ticket": { "comment": {"body": ' . $json_body . ' } +} }'; my $response = $ua->put($url, Content => $data); # Check for HTTP error codes if (! $response->is_success) { die 'http status: ' . $response->code . ' ' . $response->mess +age; } print "\n--- response->code ---\n" . $response->code . "\n"; print "\n--- response->message ---\n" . $response->message. "\n"; print "\n--- response->content ---\n" . $response->content() . "\n +"; print "\n--- response->header ---\n" . $response->header("WWW-Aut +henticate"); }

In reply to posting a message with LWP fails on Windows 2016 by fredho

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.