Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send PUT method? #15

Open
gustawdaniel opened this issue May 30, 2018 · 1 comment
Open

How to send PUT method? #15

gustawdaniel opened this issue May 30, 2018 · 1 comment

Comments

@gustawdaniel
Copy link

No description provided.

@gustawdaniel
Copy link
Author

I wrote the following code and it works

#!/bin/bash/env perl6

use Net::HTTP::GET;

my %header := {
    :Authorization("Bearer govj-XvtvL_C8v_EfZeKeCnL4z_jW3OUKoF-_y7OaB_"),
    :Content-Type("application/json")
};

my $url =  Net::HTTP::URL.new("http://localhost:3000/api/product");
my $body = '[{"id":4,"name":"D"}]';
my $req = Net::HTTP::Request.new(:$url, :$body, :method<PUT>, :%header); #.body.decode
my $trans = Net::HTTP::Transport.new;
my $response  = $trans.round-trip($req);

say $response.body.decode;

But is there method to make it shorter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant