Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, how can I remove word "headers" from code please?

use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
# set custom HTTP request header fields
my $req = HTTP::Request->new(POST => $server_endpoint);
$req->header('content-type' => 'application/json');
# add POST data to HTTP request body
$req->content($xjson);
my $resp = $ua->request($req);
if ($resp->is_success) {
    my $message = $resp->decoded_content;
    print  DATA "Received reply: $message\n";
}
else {
    print  DATA  "HTTP POST error code: ", $resp->code, "\n";
    print DATA  "HTTP POST error message: ", $resp->message, "\n";
}


close DATA;

#print  $xjson . "\n";


What I have tried:

My output:
{"@timestamp":"2021-10-18T13:20:12.039Z","host":"11.22.33.44","message":"","headers":{"request_method":"GET","http_host":null,"http_version":"HTTP/1.0","http_accept":null,"http_user_agent":null,"request_path":"/bad-request"}}
{"GENCONDNAME":" Chat Event Duration ","GENMSGTEXT":" ","GENHOSTNAME":" blabla ","@timestamp":"2021-10-18T13:21:54.002Z","host":"11.22.33.44","headers":{"request_method":"POST","http_host":"12.22.33.44","content_length":"240","http_version":"HTTP/1.1","te":"deflate,gzip;q=0.3","connection":"TE, close","content_type":"application/json","http_accept":null,"http_user_agent":"libwww-perl/6.05","request_path":"/"},"GENCONDDESC":" Time spent processing was greater then limit ","GENCELEK":"SAS_CALLC","GENAPLIKACE":" ocs_contactsrv_p "}
Posted
Comments
Mohibur Rashid 19-Oct-21 3:04am    
Question is not clear. Do you want to drop headers object from the json data?
Member 15251555 19-Oct-21 3:47am    
behind host address is a word "headers" . I think this.
Mohibur Rashid 19-Oct-21 4:10am    
Exactly, that's headers object. This data is in json format. You can consider to install JSON library and use the library to remove headers object.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900