SharePoint 2016 on premise
Site Collection admin
Using ListData.svc, I can create list items.
Exact code works with SP10 with no errors.
Using the code below, I'm able to upload a file, but I'm receiving an error.
string sharePointSvc = "https://sp2016.some.url/sites/random/_vti_bin/ListData.svc";
using (FileStream file = File.Open(@"C:\test1.docx", FileMode.Open))
{
ServRef.RandomDataContext ctx = new ServRef.RandomDataContext(new Uri(sharePointSvc));
ctx.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
string filename = Path.GetFileNameWithoutExtension(file.Name);
string path = "/sites/random/dropofflibrary/" + Path.GetFileName(file.Name);
string contentType = "Interest Summary";
ServRef.DropOffLibraryItem documentItem = new ServRef.DropOffLibraryItem()
{
ContentType = contentType,
Name = filename,
Title = filename
};
ctx.AddToDropOffLibrary(documentItem);
ctx.SetSaveStream(documentItem, file, false, contentType, path);
try
{
ctx.SaveChanges();
}
catch (Exception ex)
{
var err = ex.Message;
throw;
}
}
Errors
Output error: An error occurred while processing this request.
Errors from Fiddler:
Auth:
No Proxy-Authenticate Header is present.
No WWW-Authenticate Header is present.
Caching:
Under RFC2616, HTTP/500 responses will not be cached regardless of what caching headers may be present. HTTP/1.1 Cache-Control Header is present: no-cache
This response does not specify explicit HTTP Cache Lifetime information and does not specify a Last-Modified date. Heuristic expiration is typically based on Last-Modified date. Lacking Last-Modified, this response may be revalidated on every use or once per browsing session, depending on the browser configuration.
This response contains neither an ETAG nor a Last-Modified time. This will prevent a Conditional Revalidation of this response.