in reply to Re^2: Changing data in Sharepointlist via LWP/JSON - OData.ODataContentTypeException :(
in thread Changing data in Sharepointlist via LWP/JSON - OData.ODataContentTypeException :(

Just for completeness. I now have a working example of how to change data in Sharepoint via Perl.
#!/usr/bin/perl use strict; use LWP::UserAgent; use LWP::Authen::Ntlm; use HTTP::Request::Common; use JSON; use Data::Dumper; # config my $host = "mysite.local"; my $user = 'domain\spadmin'; my $pass = "iLikeMyBike"; my $resource = "business/mytestsite"; my $listid = "1bd8d1bc-e797-41ae-97c0-e3876406d0fe"; my $itemindex = 20; # globals my $digest; # create useragent my $ua = LWP::UserAgent->new( keep_alive => 1); $ua->credentials("$host:443", "", $user, $pass); $ua->default_header('Accept' => "application/json;odata=verbose"); $ua->timeout( 10 ); # get digest my $response = $ua->post( "https://$host/$resource/_api/contextinfo" + ); if ($response->is_success) { my $json = decode_json $response->decoded_content; $digest = $json->{d}->{GetContextWebInformation}->{FormDigestValue +}; } else { die $response->status_line; } # post data my $msg = '{"__metadata":{"type":"SP.Data.DocLibItem"},"Title":"This + is my testtitle"}'; my $req = POST "https://$host/$resource/_api/lists('$listid')/items( +$itemindex)", "Content-type" => "application/json;odata=verbose", "X-HTTP-Method" => "MERGE", "X-RequestDigest" => $digest, "IF-MATCH" => "*", "Content" => $msg; $response = $ua->request( $req ); my $json = decode_json $response->decoded_content; print Dumper( $json ); if ($response->is_success) { print "place to be :)\n"; } else { die $response->status_line; }
  • Comment on Re^3: Changing data in Sharepointlist via LWP/JSON - OData.ODataContentTypeException :(
  • Download Code

Replies are listed 'Best First'.
Re^4: Changing data in Sharepointlist via LWP/JSON - OData.ODataContentTypeException :(
by randallard (Initiate) on Jun 12, 2014 at 18:43 UTC

    Hey thanks so much for posting this conclusion, it helped me out a lot