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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |