{"_id":"56ad2a922a7860170013f70d","category":{"_id":"56abdd81d4432d1900eed235","__v":6,"version":"569f9cf6650e1d1900f96b5e","pages":["56abddd30b9e0b0d006162b1","56abde024e4b730d009eb11a","56abe05f678b58170031ec46","56ad2053d21f1b0d00fd2f82","56ad2a922a7860170013f70d","56ad2b663fc1020d009776da"],"project":"569f9cf6650e1d1900f96b5b","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-29T21:45:37.383Z","from_sync":false,"order":2,"slug":"introduction","title":"Introduction"},"githubsync":"","user":"5582e90181672a3900bb4fc7","version":{"_id":"569f9cf6650e1d1900f96b5e","project":"569f9cf6650e1d1900f96b5b","__v":12,"createdAt":"2016-01-20T14:43:02.785Z","releaseDate":"2016-01-20T14:43:02.785Z","categories":["569f9cf7650e1d1900f96b5f","56abdd81d4432d1900eed235","56abe0558beeff0d003b8118","56ad2f8b1c09150d00a183a8","56ad4e1cd21f1b0d00fd2f97","56b00ad88f7a4f0d0029dc92","56b2432e9621f20d00efb2bd","56b25826147e900d00d6497a","56b7af2a4b372d2100722c48","56b8c4d938b1070d0028920f","56b8cdab14feef0d0082415d","58599813cf9e112d0032cdab"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":3,"project":"569f9cf6650e1d1900f96b5b","parentDoc":null,"updates":["5d4833fa715bdb001f0bb431"],"next":{"pages":[],"description":""},"createdAt":"2016-01-30T21:26:42.242Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","examples":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"## Perl and LWP \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"In the test environment, Perl and LWP based requests may fail and return the error: **500 Can't connect to admin.test.hostedemail.com:443 (certificate verify failed)** due to the test environment SSL certificate being invalid.\",\n  \"title\": \"Note:\"\n}\n[/block]\nTo bypass certificate checking, you can use the following line in your script:\n\n$ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;\n\n\nThe Perl script below lists a number of modules that need to be installed. In addition to these, and to make an HTTPS connection using LWP, please ensure you have the following module installed:\n\n**LWP::Protocol::https** \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"!/usr/bin / perl\\nuse strict;\\nuse warnings;\\nuse JSON;\\nuse LWP::UserAgent;\\nuse Data::Dumper;\\nmy $api_url = 'https://admin.a.hostedemail.com/api';\\nmy $method = 'get_user';\\nmy $url = $api_url.$method;\\nmy $credentials = {\\n    'user' => 'domain_admin:::at:::example.com',\\n    'password' => 'sw0rdf1sh'\\n};\\nmy $user = 'someguy@exampley.com';\\nmy % request_body = (\\n    'credentials' => $credentials,\\n    'user' => $user,\\n);\\n#encode request in JSON\\nmy $json_request = encode_json(\\\\ % request_body);\\n#send request to API\\nmy $ua = LWP::UserAgent - > new;\\nmy $request = HTTP::Request - > new(POST => $url);\\n$request - > content_type('application/json');\\n$request - > content($json_request);\\nmy $response = $ua - > request($request);\\nif ($response - > is_success)# HTTP success \\n{\\n    #convert response from JSON to a perl hash\\n    my $response_body = from_json($response - > content());\\n    print Dumper $response_body;\\n} \\nelse \\n{\\n    print \\\"Something went terribly wrong\\\\n\\\";\\n    print $response - > status_line, \\\"\\\\n\\\";\\n}\",\n      \"language\": \"perl\",\n      \"name\": \"  \"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"example-clients","type":"basic","title":"Example clients"}
## Perl and LWP [block:callout] { "type": "info", "body": "In the test environment, Perl and LWP based requests may fail and return the error: **500 Can't connect to admin.test.hostedemail.com:443 (certificate verify failed)** due to the test environment SSL certificate being invalid.", "title": "Note:" } [/block] To bypass certificate checking, you can use the following line in your script: $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; The Perl script below lists a number of modules that need to be installed. In addition to these, and to make an HTTPS connection using LWP, please ensure you have the following module installed: **LWP::Protocol::https** [block:code] { "codes": [ { "code": "!/usr/bin / perl\nuse strict;\nuse warnings;\nuse JSON;\nuse LWP::UserAgent;\nuse Data::Dumper;\nmy $api_url = 'https://admin.a.hostedemail.com/api';\nmy $method = 'get_user';\nmy $url = $api_url.$method;\nmy $credentials = {\n 'user' => 'domain_admin@example.com',\n 'password' => 'sw0rdf1sh'\n};\nmy $user = 'someguy@exampley.com';\nmy % request_body = (\n 'credentials' => $credentials,\n 'user' => $user,\n);\n#encode request in JSON\nmy $json_request = encode_json(\\ % request_body);\n#send request to API\nmy $ua = LWP::UserAgent - > new;\nmy $request = HTTP::Request - > new(POST => $url);\n$request - > content_type('application/json');\n$request - > content($json_request);\nmy $response = $ua - > request($request);\nif ($response - > is_success)# HTTP success \n{\n #convert response from JSON to a perl hash\n my $response_body = from_json($response - > content());\n print Dumper $response_body;\n} \nelse \n{\n print \"Something went terribly wrong\\n\";\n print $response - > status_line, \"\\n\";\n}", "language": "perl", "name": " " } ] } [/block]