Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

POST file through REST::Client [SOLVED]

by thanos1983 (Vicar)
on Apr 10, 2018 at 11:08 UTC ( #1212636=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    use strict;
    ...
    $ perl restClient.pl
    $VAR1 = 'Not a SCALAR reference at /usr/local/share/perl/5.22.1/LWP/Pr
    +otocol/http.pm line 260.
    ';
    
  2. or download this
    package ClientRest;
    
    ...
    }
    
    1;
    
  3. or download this
    $ curl -u user:password -H "Content-Type: multipart/form-data" -H "Acc
    +ept: application/json" -H "Expect:" -F file=@test.txt -X POST http://
    +127.0.0.1:8000/upload/ | jq '.'
      % Total    % Received % Xferd  Average Speed   Time    Time     Time
    +  Current
    ...
      "language": "perl",
      "style": "emacs"
    }
    
  4. or download this
    $ perl restClient.pl
    $VAR1 = 'Not a SCALAR reference at /usr/local/share/perl/5.22.1/LWP/Pr
    +otocol/http.pm line 260.
    ';
    
  5. or download this
    else {
        # Set (or override) Content-Length header
    ...
        hlist_remove(\@h, 'Content-Length');
        }
    }
    
  6. or download this
    my $headers = { "Content" => ['file' => [$options{file}]],
            "Content-type" => 'multipart/form-data',
            "Authorization" => 'Basic ' .
                encode_base64($options{username} . ':' . $options{password
    +}) };
    
  7. or download this
    # module part
    sub postSnippets {
    ...
              'url' => 'http://127.0.0.1:8000/snippets/2/',
              'owner' => 'user'
            };
    
  8. or download this
    $VAR1 = '{"detail":"Multipart form parse error - Invalid boundary in m
    +ultipart: None"}';
    
  9. or download this
    sub postSnippetsFile {
        my ( $self, %options ) = @_;
    ...
                    $headers );
        return $self->{_client}->responseContent();
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1212636]
Front-paged by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-07-17 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (354 votes). Check out past polls.

    Notices?