I just looked at your code again, and I find it a very weird approach to (re)set $ua->default_header for each request. The more traditional way would be to simply construct the appropriate HTTP::Request objects instead. At least from my spurious attempts, it does not feel as if a POST request uses the ->default_header:
> perl -MLWP::UserAgent -e "$ua=LWP::UserAgent->new();$ua->default_hea +der('Content-type' => 'application/json;odata=verbose'); $ua->add_handler('request_send',sub{shift->dump;return}); $ua->post('http://localhost:1234',{foo => bar})" POST http://localhost:1234 User-Agent: libwww-perl/6.04 Content-Length: 7 Content-Type: application/x-www-form-urlencoded foo=bar
Explicitly creating the HTTP::Request and then sending that one seems to create headers that I expect:
>perl -MLWP::UserAgent -MHTTP::Request::Common -e "$ua=LWP::UserAgent- +>new(); req= POST 'http://localhost:1234', 'Content-type' => 'applicati +on/json;odata=verbose', Content => { foo => 'bar' }; $ua->add_handler('request_send',sub{shift->dump;return}); $ua->req +uest($req)" POST http://localhost:1234 User-Agent: libwww-perl/6.04 Content-Length: 7 Content-Type: application/json;odata=verbose foo=bar
So I suggest you do more debugging on whether the values you think you are sending actually get send, and you also switch to the more common and accepted use of ->default_header() of setting only default headers and not per-request specific headers.
In reply to Re: Changing data in Sharepointlist via LWP/JSON - OData.ODataContentTypeException :(
by Corion
in thread Changing data in Sharepointlist via LWP/JSON - OData.ODataContentTypeException :(
by timb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |