Hi there,
for quite a while I'm retrieving data from Sharepoint using perl on my linuxmachine.
Now I also have to change data on SP.
I added some logic to retrieve the digesttoken (needed for posting) but altough it looked promising at the beginning now I'm stuck with that really annoying error:
"A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'application/atom+xml;type=entry, application/atom+xml, application/json;odata=verbose' matches the content type 'application/json'."I've already spent days searching the web for a solution, but was unsuccessful so far.
Maybe there is a monk out there who can help me out.
This is my code:
#!/usr/bin/perl use strict; use LWP::UserAgent; use LWP::Authen::Ntlm; use JSON; use Data::Dumper; # config my $host = "mysite.local"; my $user = 'domain\spadmin'; my $pass = "sucKmYducK"; 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"}'; $ua->default_header ( 'Accept' => "application/json;odata=verbose", 'Content-type' => "application/json;odata=verbose", 'Content-length' => length( $msg ), 'X-HTTP-Method' => "MERGE", 'X-RequestDigest' => $digest, 'IF-MATCH' => "*" ); my $response = $ua->post ( "https://$host/$resource/_api/lists('$listid')/items($itemindex)", { data => $msg } ); my $json = decode_json $response->decoded_content; print Dumper( $json ); if ($response->is_success) { print "place to be :)\n"; } else { die $response->status_line; }
tia
tiMb
In reply to Changing data in Sharepointlist via LWP/JSON - OData.ODataContentTypeException :( by timb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |