in reply to Asking for help with simple api post via perl
Using my convenient curl-to-LWP service, I get the following code:
#!perl use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new( 'send_te' => '0' ); my $r = HTTP::Request->new( 'POST' => 'https://api.mysite.com/2022-01-08/enrich/upload', [ 'Accept' => '*/*', 'Authorization' => 'Basic YW55X3N0cmluZzp7c2VjdXJlX3Rva2VufQ= +=', 'User-Agent' => 'curl/7.55.1', 'Content-Length' => '52', 'Content-Type' => 'application/x-www-form-urlencoded' ], "data=testme\x40mysite.com&webhook=http://mywebhook.com/" ); my $res = $ua->request( $r, ); __END__ Created from curl command line curl -X POST https://api.mysite.com/2022-01-08/enrich/upload -u any_s +tring:{secure_token} -d data="testme@mysite.com" -d webhook="http://m +ywebhook.com/"
The main difference is that the content type is application/x-www-form-urlencoded instead of form-data (which I don't know). I don't see where else the generated code is substantially different from your (non-working) Perl code, but if the generated code works where yours doesn't, maybe it is the Content-Type header or that the receiving site cares about the Curl User-Agent header or something like that...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Asking for help with simple api post via perl
by EPSS (Initiate) on Mar 16, 2022 at 22:41 UTC |