Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

I am working against the salesforce rest API with lwp::useragent.

I have to use the HTTP patch request.

Forget and post requests we get to use the following code:

require LWP::UserAgent;

my $ua = LWP::UserAgent->new;

$ua->timeout(10);

$ua->env_proxy;

my $get_response = $ua->get('http://search.cpan.org/',x=>'y');

my $post_response = $ua->post('http://search.cpan.org/',x=>'y');

Unfortunately, this does not work

   my $patch_response = $ua->patch('http://search.cpan.org/',x=>'y');

I don't find how to do it with this module.

There is a workaround to this problem like explained here How do I send a request using the PATCH method for a Salesforce update?

This works but this is not a nice solution.

I saw that with python it is possible to make explicitly patch requests How do I make a PATCH request in Python? so I assume that there is also an option with Perl.

1 Answer

0 votes
by (32.1k points)
edited by

This has recently got a whole lot easier. PATCH is now implemented (like POST) in HTTP::Message.

First, update the HTTP::Message module (to 6.13 or later).

Then

my %fields = ( title => 'something', body => something else');

my $ua = LWP::UserAgent->new();

my $request = HTTP::Request::Common::PATCH( $url, [ %fields ] );

my $response = $ua->request($request);

To learn in-depth about Workflow in Salesforce, sign up for an industry-based Salesforce Certification! 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...