From a C# library I need to use the SP rest Api to upload a document to a document library then set properties for it.
I almost have this working by making the following sequence of calls:
- Post to /contextinfo to get the FormDigestValue
- Post the binary to /Files/Add including the digest in the header property X-RequestDigest
- Get /ListItemAllFields the digest in the header property X-RequestDigest
The next call is a Post to _api/web/lists/GetByTitle('library name')/Items(157)
The same digest value is included in the header property X-RequestDigest as can be seen below:
POST
https://xxx.uk/_api/web/lists/GetByTitle('AssetMgmtEfilesDemo')/Items(157) HTTP/1.1
Accept: application/json, application/xml; odata=verbose
X-HTTP-Method: MERGE
IF-MATCH: *
X-RequestDigest: 0x01426A9818F7145E12BC2E99246C7E00AC1A3905D27204C783107FDDE806D2629171FAD8DCC61008E109DD9948BEB4208DC62107B2336B1228ABA143A2D5B3C6,19 Feb 2019 15:20:44 -0000
Content-Type: application/json; charset=utf-8
Host: xxx.uk
Content-Length: 359
Expect: 100-continue
{
__metadata":{
"type":"SP.Data.AssetMgmtEfilesDemoItem"
},
"UPRN":"U1",
"KeystoneDocType":"Document"
}
My problem is that for this request, I get a "403 forbidden" response.
Can anyone see where I went wrong?
