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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.