in reply to Brackets in LWP Post

Further arguments can be given to initialize the headers of the request. These are given as separate name/value pairs.
(from LWP::UserAgent)

You are POSTing with the wrong headers: you are giving a meaningless hashref whereas it should be dereferenced to provide name/value pairs. (that said, I can not say if all else is OK)

return $ua->post( $self->{'auth'}->api_url_base . 'shares', Content => encode_json($json), %$header, #<<<<< );

bw, bliako

Replies are listed 'Best First'.
Re^2: Brackets in LWP Post
by Bod (Parson) on May 11, 2021 at 18:42 UTC
    You are POSTing with the wrong headers:

    Fabulous!
    You are spot on...dereferencing $header makes it work as it should :) Many, many thanks.

    Bizarrely, the hashref worked to authorise a GET call to a different endpoint to fetch information about the current user. I used that to check that the headers were being passed correctly. Strange how it works for a GET but not a POST.

      Bizarrely, the hashref worked to authorise a GET call

      that's strange because LWP::UserAgent says that they all use the same notation to pass the headers: Additional headers and content options are the same as for the "get" in LWP::UserAgent method.

      anyway, cool project!