Subject: | Enable PUT method in Xero agent |
Some Xero API methods require PUT method. Attached is a simple patch to enable that.
Regards
Racke
Subject: | 0001-Enable-PUT-method-in-Xero-agent.patch |
From 76c60c145387b1b2eb7cfef65b71cfaed3e6a9f9 Mon Sep 17 00:00:00 2001
From: "Stefan Hornburg (Racke)" <racke@linuxia.de>
Date: Fri, 17 Aug 2018 10:11:59 +0200
Subject: [PATCH] Enable PUT method in Xero agent.
---
lib/WebService/Xero/Agent.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/WebService/Xero/Agent.pm b/lib/WebService/Xero/Agent.pm
index 4ca7f20..013c813 100644
--- a/lib/WebService/Xero/Agent.pm
+++ b/lib/WebService/Xero/Agent.pm
@@ -178,7 +178,7 @@ sub do_xero_api_call
nonce => 'ccp' . md5_base64( join('', rand_chars(size => 8, set => 'alphanumeric')) . time ),
);
$opts{verifier} = $self->{verifier} if defined $self->{verifier};
- $opts{extra_params} = { xml => $xml} if ( $method eq 'POST' and defined $xml );
+ $opts{extra_params} = { xml => $xml} if ( ($method eq 'POST' or $method eq 'PUT') and defined $xml );
my $access = Net::OAuth->request("protected resource")->new( %opts );
@@ -193,7 +193,7 @@ sub do_xero_api_call
}
my $req = HTTP::Request->new( $method, $uri );
- if ( $method eq 'POST' )
+ if ( $method eq 'POST' or $method eq 'PUT' )
{
$req->header( 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8');
$req->header( 'Accept' => 'application/json');
--
2.18.0