Problem :
When we are trying to insert an item into a newly created SharePoint list using Visual Studio code
We keep getting a NotSupportedException :The response to this POST request did not contain a 'location' header. That is not supported by this client.
If we do a recycle of the SharePoint - 80 website Application Pool in IIS, the program is able to insert the item but after the program is reran for a second time the Exception is thrown again…?
Database : SQL Server 11.0.5548
SharePoint 2013 SP1 (15.0.4569.1506)
User that run the code: farm account
System.NotSupportedException was caught
HResult=-2146233067
Message=The response to this POST request did not contain a 'location' header. That is not supported by this client.
Source=Microsoft.Data.Services.Client
StackTrace:
at System.Data.Services.Client.BaseSaveResult.HandleOperationResponseHeaders(HttpStatusCode statusCode, HeaderCollection headers)
at System.Data.Services.Client.SaveResult.CreateNextChange()
at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
at System.Data.Services.Client.DataServiceContext.SaveChanges()
at ConsoleApplication1.Module1.Main() in C:\Users\user1\Documents\Visual Studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Module1.vb:line 15
InnerException:
Code :
Imports ConsoleApplication1.ServiceReference2
ModuleModule1
Sub Main()
Try
Dim datacontextAsNewRootDataContext(NewUri("http://myserver/_vti_bin/listdata.svc/"))
datacontext.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim tiAsNewRootListItem()
ti.Title = "toto"
datacontext.AddToRootList(ti)
datacontext.SaveChanges()
Catch exAsException
Throw ex
EndTry
EndSub
EndModule